Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type response struct {
- OK bool `json:"ok"`
- Description string `json:"description"`
- Result interface{} `json:"result"`
- }
- func (telegramBot *TelegramBot) makeRequest(request *http.Request) (error, interface{}) {
- resp, err := telegramBot.client.Do(request)
- if err != nil {
- return err, nil
- }
- defer resp.Body.Close()
- decoder := json.NewDecoder(resp.Body)
- respon := response{}
- decoder.Decode(&respon)
- if !respon.OK {
- return errors.New(respon.Description), nil
- }
- return nil,respon.Result
- }
Advertisement
Add Comment
Please, Sign In to add comment