Refactoring of api routes

This commit is contained in:
Torkel Ödegaard
2015-01-14 14:25:12 +01:00
parent 166ce7d2ae
commit 5e18afe916
4 changed files with 60 additions and 46 deletions
+5
View File
@@ -3,6 +3,7 @@ package middleware
import (
"encoding/json"
"strconv"
"strings"
"github.com/Unknwon/macaron"
"github.com/macaron-contrib/session"
@@ -62,6 +63,10 @@ func (ctx *Context) JsonOK(message string) {
ctx.JSON(200, resp)
}
func (ctx *Context) IsApiRequest() bool {
return strings.HasPrefix(ctx.Req.URL.Path, "/api")
}
func (ctx *Context) JsonApiErr(status int, message string, err error) {
resp := make(map[string]interface{})