groups

command
v14.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL