Adds NewRouter

This commit is contained in:
2015-08-26 14:08:18 +02:00
parent f64f225b18
commit 91908f15e7

19
router.go Normal file
View File

@@ -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)
}
}