From 20d0108b5551cd87d0809c8ccf8636626d84bb5d Mon Sep 17 00:00:00 2001 From: Nikita Tokarchuk Date: Fri, 3 Dec 2021 03:59:06 +0100 Subject: [PATCH] Add ghost backend get-post-by-slug request --- frontend/ghost/client.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/frontend/ghost/client.go b/frontend/ghost/client.go index 8222cee..504ca84 100644 --- a/frontend/ghost/client.go +++ b/frontend/ghost/client.go @@ -12,6 +12,7 @@ import ( const ( ghostAPIPrefix = "/ghost/api/v3/" ghostAPIGetPosts = ghostAPIPrefix + "content/posts/" + ghostAPIGetPostBySlug = ghostAPIPrefix + "content/posts/slug/%s/" ghostAPIGetPageBySlug = ghostAPIPrefix + "content/pages/slug/%s/" ) @@ -109,4 +110,18 @@ func (g *HTTPClient) GetPosts(params ...QueryParam) (posts *Posts, err error) { } return -} \ No newline at end of file +} + +// GetPostBySlug returns the only one post using slug filter +func (g *HTTPClient) GetPostBySlug(slug string, params ...QueryParam) (posts *Posts, err error) { + + posts = &Posts{} + method := fmt.Sprintf(ghostAPIGetPostBySlug, slug) + + err = g.doQuery(method, posts, params...) + if err != nil { + posts = nil + } + + return +}