macaron transition progress

This commit is contained in:
Torkel Ödegaard
2014-10-05 21:13:07 +02:00
parent 201e1d3e6d
commit 222319d924
11 changed files with 403 additions and 38 deletions
+10 -4
View File
@@ -1,7 +1,8 @@
package middleware
import (
"time"
"encoding/json"
"io/ioutil"
"github.com/Unknwon/macaron"
"github.com/macaron-contrib/session"
@@ -21,13 +22,12 @@ type Context struct {
}
func GetContextHandler() macaron.Handler {
return func(c *macaron.Context) {
return func(c *macaron.Context, sess session.Store) {
ctx := &Context{
Context: c,
Session: sess,
}
ctx.Data["PageStartTime"] = time.Now()
c.Map(ctx)
}
}
@@ -50,3 +50,9 @@ func (ctx *Context) Handle(status int, title string, err error) {
ctx.HTML(status, "index")
}
func (ctx *Context) JsonBody(model interface{}) bool {
b, _ := ioutil.ReadAll(ctx.Req.Body)
err := json.Unmarshal(b, &model)
return err == nil
}