⚡ GOTTA GO FAST
This commit is contained in:
parent
a7791254d7
commit
c65a51182d
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
2
page.go
2
page.go
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
13
telegraph.go
13
telegraph.go
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue