add result limiting in blog posts
This commit is contained in:
parent
ab89bda819
commit
0d58fd3f63
|
@ -103,7 +103,7 @@ func BlogPostsGET(md common.MethodData) common.CodeMessager {
|
||||||
// create response and return
|
// create response and return
|
||||||
var r blogPostsResponse
|
var r blogPostsResponse
|
||||||
r.Code = 200
|
r.Code = 200
|
||||||
r.Posts = posts
|
r.Posts = blogLimit(posts, md.Query("l"))
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,6 +173,14 @@ func BlogPostsGET(md common.MethodData) common.CodeMessager {
|
||||||
|
|
||||||
var r blogPostsResponse
|
var r blogPostsResponse
|
||||||
r.Code = 200
|
r.Code = 200
|
||||||
r.Posts = posts
|
r.Posts = blogLimit(posts, md.Query("l"))
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func blogLimit(posts []blogPost, s string) []blogPost {
|
||||||
|
i := common.Int(s)
|
||||||
|
if i >= len(posts) || i < 1 {
|
||||||
|
return posts
|
||||||
|
}
|
||||||
|
return posts[:i]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user