Documentation
¶
Overview ¶
Route groups: child routers that inherit a path prefix and middleware.
app.Router(relativePath, ...) returns a child router that inherits the parent's path prefix and middleware. Groups nest to any depth, iris.Handler values passed next to the path become the group's middleware, and the closure form configures the child router in place.
Learn: group routes under one prefix with app.Router, nest groups and attach middleware to a single group. Before: ../path-parameters
Run:
go run main.go
Try:
curl -i http://localhost:8080/api/status # 200, X-Group: api curl -i http://localhost:8080/api/v1/users/42 # 200, X-Group: api, then X-Group: v1 curl http://localhost:8080/reports # 200, ["weekly","monthly"] curl -i http://localhost:8080/admin/stats # 401 curl -i -H "X-Token: s3cret" http://localhost:8080/admin/stats # 200
Next: ../subdomains
Click to show internal directories.
Click to hide internal directories.