diff --git a/router.go b/router.go new file mode 100644 index 0000000..56fc3c1 --- /dev/null +++ b/router.go @@ -0,0 +1,19 @@ +package narco + +import ( + "net/http" + + "github.com/codemodus/chain" + "github.com/julienschmidt/httprouter" + "golang.org/x/net/context" +) + +type HandlerFunc func(ctx context.Context, rw http.ResponseWriter, req *http.Request, ps httprouter.Params) + +func EndChain(chain chain.Chain, h HandlerFunc) httprouter.Handle { + return func(rw http.ResponseWriter, req *http.Request, ps httprouter.Params) { + chain.EndFn(func(ctx context.Context, rw_ http.ResponseWriter, req_ *http.Request) { + h(ctx, rw_, req_, ps) + }).ServeHTTP(rw, req) + } +}