routers: able to migrate repo from local path

- modules/middleware/context.go: add HandleAPI method
This commit is contained in:
Unknwon
2015-02-22 09:49:25 -05:00
parent c753fdceaf
commit 059338139c
7 changed files with 74 additions and 53 deletions

View File

@ -130,6 +130,18 @@ func (ctx *Context) Handle(status int, title string, err error) {
ctx.HTML(status, base.TplName(fmt.Sprintf("status/%d", status)))
}
func (ctx *Context) HandleAPI(status int, obj interface{}) {
var message string
if err, ok := obj.(error); ok {
message = err.Error()
} else {
message = obj.(string)
}
ctx.JSON(status, map[string]string{
"message": message,
})
}
func (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{}) {
modtime := time.Now()
for _, p := range params {