-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Expand file tree
/
Copy pathmain.go
More file actions
29 lines (22 loc) · 530 Bytes
/
main.go
File metadata and controls
29 lines (22 loc) · 530 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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")
}