Reverse Lookups
Route naming
package main
import "github.com/kataras/iris/v12"
func main() {
app := iris.New()
// define a function
h := func(ctx iris.Context) {
ctx.HTML("<b>Hi</b1>")
}
// handler registration and naming
home := app.Get("/", h)
home.Name = "home"
// or
app.Get("/about", h).Name = "about"
app.Get("/page/{id}", h).Name = "page"
app.Listen(":8080")
}Route reversing AKA generating URLs from the route name
Using route names in code
Last updated
Was this helpful?