Convers query results to CSV with format flag

This commit is contained in:
Dan Sosedoff
2014-10-10 18:56:02 -05:00
parent 2e766af361
commit 38cef071e8
2 changed files with 42 additions and 0 deletions

12
api.go
View File

@@ -68,5 +68,17 @@ func API_HandleQuery(query string, c *gin.Context) {
return
}
q := c.Request.URL.Query()
format := q["format"][0]
if format == "" {
format = "json"
}
if format == "csv" {
c.String(200, result.CSV())
return
}
c.JSON(200, result)
}