Adds NewRouter
This commit is contained in:
19
router.go
Normal file
19
router.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user