telegraph/get_page.go

27 lines
567 B
Go
Raw Normal View History

2017-09-04 21:09:59 +00:00
package telegraph
import (
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
// GetPage get a Telegraph page. Returns a Page object on success.
func GetPage(path string, returnContent bool) (*Page, error) {
args := http.AcquireArgs()
2017-09-04 21:09:59 +00:00
// If true, content field will be returned in Page object.
args.Add("return_content", strconv.FormatBool(returnContent))
body, err := request("getPage", path, args)
2017-09-04 21:09:59 +00:00
if err != nil {
return nil, err
}
var resp Page
err = json.Unmarshal(*body.Result, &resp)
return &resp, err
}