Refactoring of api routes
This commit is contained in:
@@ -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{})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user