telegraph/get_page.go

28 lines
613 B
Go
Raw Normal View History

2017-09-04 21:09:59 +00:00
package telegraph
import (
2018-07-27 11:51:14 +00:00
gopath "path"
2017-09-04 21:09:59 +00:00
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
// GetPage get a Telegraph page. Returns a Page object on success.
2018-07-27 11:51:14 +00:00
func GetPage(path string, returnContent bool) (r *Page, err error) {
args := http.AcquireArgs()
2018-07-27 11:51:14 +00:00
defer http.ReleaseArgs(args)
args.Add("path", path) // required
2017-09-04 21:09:59 +00:00
args.Add("return_content", strconv.FormatBool(returnContent))
2018-07-27 11:51:14 +00:00
dst := new(Response)
dst, err = makeRequest(gopath.Join("getPage", path), args)
2017-09-04 21:09:59 +00:00
if err != nil {
return nil, err
}
2018-07-27 11:51:14 +00:00
r = new(Page)
err = json.Unmarshal(*dst.Result, r)
return
2017-09-04 21:09:59 +00:00
}