1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +00:00

fix https://github.com/kataras/iris/issues/1713 and add a simple usage example of the 'RemoveHandler'

This commit is contained in:
Gerasimos (Makis) Maropoulos
2021-01-27 01:22:20 +02:00
parent 197df1ef64
commit f7757c0793
7 changed files with 60 additions and 34 deletions

View File

@@ -0,0 +1,29 @@
package main
import "github.com/kataras/iris/v12"
func main() {
app := newApp()
app.Listen(":8080")
}
func newApp() *iris.Application {
app := iris.New()
api := app.Party("/api")
api.Use(myMiddleware)
users := api.Party("/users")
users.Get("/", usersIndex).RemoveHandler(myMiddleware)
// OR for all routes under a Party (or Application):
// users.RemoveHandler(...)
return app
}
func myMiddleware(ctx iris.Context) {
ctx.WriteString("Middleware\n")
}
func usersIndex(ctx iris.Context) {
ctx.WriteString("OK")
}