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 package telegraph
import ( import (
"encoding/json"
"fmt" "fmt"
"strings" "strings"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp" http "github.com/valyala/fasthttp"
) )

View File

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

View File

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