mirror of
https://github.com/mainnika/nikita-tokarch-uk.git
synced 2026-05-25 01:03:35 +00:00
Add ghost backend get-page-by-slug request
This commit is contained in:
@@ -10,7 +10,8 @@ import (
|
|||||||
)
|
)
|
||||||
// Ghost content data URIs:
|
// Ghost content data URIs:
|
||||||
const (
|
const (
|
||||||
ghostAPIPrefix = "/ghost/api/v3/"
|
ghostAPIPrefix = "/ghost/api/v3/"
|
||||||
|
ghostAPIGetPageBySlug = ghostAPIPrefix + "content/pages/slug/%s/"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HTTPClient implements the ghost http client
|
// HTTPClient implements the ghost http client
|
||||||
@@ -80,5 +81,19 @@ func (g *HTTPClient) doQuery(method string, v easyjson.Unmarshaler, params ...Qu
|
|||||||
|
|
||||||
err = easyjson.Unmarshal(resBytes, v)
|
err = easyjson.Unmarshal(resBytes, v)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPageBySlug returns the only one page using slug filter
|
||||||
|
func (g *HTTPClient) GetPageBySlug(slug string) (pages *Pages, err error) {
|
||||||
|
|
||||||
|
pages = &Pages{}
|
||||||
|
method := fmt.Sprintf(ghostAPIGetPageBySlug, slug)
|
||||||
|
|
||||||
|
err = g.doQuery(method, pages)
|
||||||
|
if err != nil {
|
||||||
|
pages = nil
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user