From 91908f15e74c120c2f05ce6e64127c819677cdf6 Mon Sep 17 00:00:00 2001 From: Alexandre Tuleu Date: Wed, 26 Aug 2015 14:08:18 +0200 Subject: [PATCH] Adds NewRouter --- router.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 router.go 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) + } +}