GOTTA GO FAST

This commit is contained in:
Maxim Lebedev 2017-05-12 02:06:32 +05:00
parent a7791254d7
commit c65a51182d
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
3 changed files with 9 additions and 8 deletions

View File

@ -1,10 +1,10 @@
package telegraph
import (
"encoding/json"
"fmt"
"strings"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)

View File

@ -1,10 +1,10 @@
package telegraph
import (
"encoding/json"
"fmt"
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)

View File

@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
ffjson "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
@ -133,19 +134,19 @@ type (
)
func request(url string, args *http.Args) (*Response, error) {
_, resp, err := http.Post(nil, url, args)
_, body, err := http.Post(nil, url, args)
if err != nil {
return nil, err
}
var tResp Response
if err := json.Unmarshal(resp, &tResp); err != nil {
var resp Response
if err := ffjson.Unmarshal(body, &resp); err != nil {
return nil, err
}
if !tResp.Ok {
return nil, errors.New(tResp.Error)
if !resp.Ok {
return nil, errors.New(resp.Error)
}
return &tResp, nil
return &resp, nil
}