kuvia2/pkg/example/example.go

25 lines
649 B
Go
Raw Normal View History

2022-01-14 23:09:03 +00:00
package example
import (
"github.com/flamego/flamego"
"github.com/flamego/template"
"github.com/rs/zerolog/log"
"reflect"
)
func Example() flamego.Handler {
log.Debug().Msg("Handler")
return flamego.ContextInvoker(func(c flamego.Context) {
r := c.Value(reflect.TypeOf(template.Data{})).Interface().(template.Data)
r["user_id"] = 1337
c.Next()
c.ResponseWriter().Write([]byte("Middleware"))
})
/*return flamego.ContextInvoker(func(ctx flamego.Context) {
log.Debug().Msg("Invoker")
//r := ctx.Value(reflect.TypeOf(template.Data{})).Interface().(template.Data)
//r["user_id"] = 0
//ctx.Next()
log.Debug().Msg("Done")
})*/
}