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")
	})*/
}