I'm using this implementation - https://github.com/sadhanandh/revelbasic - to build a customized REST API endpoint in Golang.
For any input parameter like, say, /brands, I have the following code -
Model:
func GetBrands(s *mgo.Session) []Brand {
var results []Brand
CollectionBrand(s).Find(bson.M{}).All(&results)
return results
}
Controller:
func (c Book) Brands() revel.Result {
b := models.GetBrands(c.MongoSession)
return c.RenderJson(b)
}
The problem is that this gives a purely json response of the data with no server status codes. I mean, the responses are like this -
[
{"data1"}, {"data2"}
]
Whereas what is actually expected is more like-
{
"apiversion": 123,
"status": "success",
"data": [{"data1"}, {"data2"}],
}
along with more information about the response such as a server status code, etc.
I can customize the response in my controller code to add these but shouldn't I be able to configure revel to do that automatically for every response?