Guest User

Untitled

a guest
May 26th, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.54 KB | None | 0 0
  1. type response struct {
  2.     OK          bool        `json:"ok"`
  3.     Description string      `json:"description"`
  4.     Result      interface{} `json:"result"`
  5. }
  6.  
  7. func (telegramBot *TelegramBot) makeRequest(request *http.Request) (error, interface{}) {
  8.     resp, err := telegramBot.client.Do(request)
  9.     if err != nil {
  10.         return err, nil
  11.     }
  12.     defer resp.Body.Close()
  13.     decoder := json.NewDecoder(resp.Body)
  14.     respon := response{}
  15.     decoder.Decode(&respon)
  16.     if !respon.OK {
  17.         return errors.New(respon.Description), nil
  18.     }
  19.     return nil,respon.Result
  20. }
Advertisement
Add Comment
Please, Sign In to add comment