forked from goffee/core
migration
This commit is contained in:
parent
7f38826b9c
commit
ac8ba89865
4 changed files with 35 additions and 35 deletions
22
core.go
22
core.go
|
|
@ -138,25 +138,25 @@ func (app *App) RegisterRoutes(routes []Route, router *httprouter.Router) *httpr
|
|||
for _, route := range routes {
|
||||
switch route.Method {
|
||||
case GET:
|
||||
router.GET(route.Path, app.makeHTTPRouterHandlerFunc(route.Handler, route.Middlewares))
|
||||
router.GET(route.Path, app.makeHTTPRouterHandlerFunc(route.Controller, route.Middlewares))
|
||||
case POST:
|
||||
router.POST(route.Path, app.makeHTTPRouterHandlerFunc(route.Handler, route.Middlewares))
|
||||
router.POST(route.Path, app.makeHTTPRouterHandlerFunc(route.Controller, route.Middlewares))
|
||||
case DELETE:
|
||||
router.DELETE(route.Path, app.makeHTTPRouterHandlerFunc(route.Handler, route.Middlewares))
|
||||
router.DELETE(route.Path, app.makeHTTPRouterHandlerFunc(route.Controller, route.Middlewares))
|
||||
case PATCH:
|
||||
router.PATCH(route.Path, app.makeHTTPRouterHandlerFunc(route.Handler, route.Middlewares))
|
||||
router.PATCH(route.Path, app.makeHTTPRouterHandlerFunc(route.Controller, route.Middlewares))
|
||||
case PUT:
|
||||
router.PUT(route.Path, app.makeHTTPRouterHandlerFunc(route.Handler, route.Middlewares))
|
||||
router.PUT(route.Path, app.makeHTTPRouterHandlerFunc(route.Controller, route.Middlewares))
|
||||
case OPTIONS:
|
||||
router.OPTIONS(route.Path, app.makeHTTPRouterHandlerFunc(route.Handler, route.Middlewares))
|
||||
router.OPTIONS(route.Path, app.makeHTTPRouterHandlerFunc(route.Controller, route.Middlewares))
|
||||
case HEAD:
|
||||
router.HEAD(route.Path, app.makeHTTPRouterHandlerFunc(route.Handler, route.Middlewares))
|
||||
router.HEAD(route.Path, app.makeHTTPRouterHandlerFunc(route.Controller, route.Middlewares))
|
||||
}
|
||||
}
|
||||
return router
|
||||
}
|
||||
|
||||
func (app *App) makeHTTPRouterHandlerFunc(h Handler, ms []Middleware) httprouter.Handle {
|
||||
func (app *App) makeHTTPRouterHandlerFunc(h Controller, ms []Middleware) httprouter.Handle {
|
||||
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
ctx := &Context{
|
||||
Request: &Request{
|
||||
|
|
@ -285,7 +285,7 @@ func (app *App) Next(c *Context) {
|
|||
if ok {
|
||||
f(c)
|
||||
} else {
|
||||
ff, ok := n.(Handler)
|
||||
ff, ok := n.(Controller)
|
||||
if ok {
|
||||
ff(c)
|
||||
}
|
||||
|
|
@ -328,7 +328,7 @@ func (cn *chain) execute(ctx *Context) {
|
|||
if ok {
|
||||
f(ctx)
|
||||
} else {
|
||||
ff, ok := i.(Handler)
|
||||
ff, ok := i.(Controller)
|
||||
if ok {
|
||||
ff(ctx)
|
||||
}
|
||||
|
|
@ -336,7 +336,7 @@ func (cn *chain) execute(ctx *Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func (app *App) combHandlers(h Handler, mw []Middleware) []interface{} {
|
||||
func (app *App) combHandlers(h Controller, mw []Middleware) []interface{} {
|
||||
var rev []interface{}
|
||||
for _, k := range mw {
|
||||
rev = append(rev, k)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue