Commit 2b91ba70 authored by Lukas Matt's avatar Lukas Matt

Add fields parameter to ApiComment.Show

parent 783f8cd4
......@@ -45,6 +45,7 @@ type ApiComment struct {
*
* @apiParam {Number} id Comment database ID
* @apiParam {String} access_token Oauth access token
* @apiParam {String} [fields] Display only specific fields, e.g. fields=ID,Person(ID:Profile(ID:ImageUrl))
*
* @apiSuccess {String} CreatedAt Timestamp of creation
* @apiSuccess {String} UpdatedAt Timestamp of last replacment
......@@ -89,11 +90,12 @@ type ApiComment struct {
*/
func (c ApiComment) Show() revel.Result {
var (
guid string
guid, fields string
comment models.Comment
)
c.Params.Bind(&guid, "id")
c.Params.Bind(&fields, "fields")
id, err := strconv.ParseUint(guid, 10, 32);
if err == nil {
......@@ -105,7 +107,7 @@ func (c ApiComment) Show() revel.Result {
c.Log.Error(TAG, "db", err, "api", ERR_NOT_FOUND)
return c.ApiError(http.StatusNotFound, ERR_NOT_FOUND)
}
return c.RenderJSON(comment)
return c.RenderJSON(helpers.SelectStructFields(comment, fields))
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment