mirror of
https://github.com/kataras/iris.git
synced 2025-12-21 11:57:02 +00:00
implement a way to add controller functions as handlers with the existing rules respected but it's a bit dirty I will change the implementation and move the mvc2 to mvc and make the api builder's PartyFunc to be a critical part of the controller and the mvc2.Mvc bind values should be also respected to the controller and more
Former-commit-id: e452a916da80d886535b8ae9625d0ba8e2b58d6e
This commit is contained in:
@@ -190,11 +190,11 @@ func (api *APIBuilder) Handle(method string, relativePath string, handlers ...co
|
||||
// otherwise use `Party` which can handle many paths with different handlers and middlewares.
|
||||
//
|
||||
// Usage:
|
||||
// app.HandleMany(iris.MethodGet, "/user /user/{id:int} /user/me", userHandler)
|
||||
// app.HandleMany("GET", "/user /user/{id:int} /user/me", genericUserHandler)
|
||||
// At the other side, with `Handle` we've had to write:
|
||||
// app.Handle(iris.MethodGet, "/user", userHandler)
|
||||
// app.Handle(iris.MethodGet, "/user/{id:int}", userHandler)
|
||||
// app.Handle(iris.MethodGet, "/user/me", userHandler)
|
||||
// app.Handle("GET", "/user", userHandler)
|
||||
// app.Handle("GET", "/user/{id:int}", userByIDHandler)
|
||||
// app.Handle("GET", "/user/me", userMeHandler)
|
||||
//
|
||||
// This method is used behind the scenes at the `Controller` function
|
||||
// in order to handle more than one paths for the same controller instance.
|
||||
@@ -536,7 +536,7 @@ func (api *APIBuilder) Any(relativePath string, handlers ...context.Handler) (ro
|
||||
func (api *APIBuilder) Controller(relativePath string, controller activator.BaseController,
|
||||
bindValues ...interface{}) (routes []*Route) {
|
||||
|
||||
registerFunc := func(ifRelPath string, method string, handlers ...context.Handler) {
|
||||
registerFunc := func(method string, ifRelPath string, handlers ...context.Handler) {
|
||||
relPath := relativePath + ifRelPath
|
||||
r := api.HandleMany(method, relPath, handlers...)
|
||||
routes = append(routes, r...)
|
||||
|
||||
Reference in New Issue
Block a user