1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-10 13:35:59 +00:00

add Party.RemoveRoute method as requested in the community chat

This commit is contained in:
Gerasimos (Makis) Maropoulos
2021-04-04 20:24:21 +03:00
parent 968dd846c2
commit ce6c455601
6 changed files with 84 additions and 19 deletions

View File

@@ -59,6 +59,7 @@
* [From func(http.HandlerFunc) http.HandlerFunc](convert-handlers/real-usecase-raven/writing-middleware/main.go)
* [Rewrite Middleware](routing/rewrite/main.go)
* [Route State](routing/route-state/main.go)
* [Remove Route](routing/remove-route/main.go)
* [Reverse Routing](routing/reverse/main.go)
* [Router Wrapper](routing/custom-wrapper/main.go)
* [Custom Router](routing/custom-router/main.go)

View File

@@ -1,11 +1,12 @@
package main
import (
"strings"
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/middleware/logger"
"github.com/kataras/iris/v12/middleware/recover"
"github.com/kataras/iris/v12/mvc"
"strings"
)
// This example is equivalent to the
@@ -47,7 +48,7 @@ func newApp() *iris.Application {
w = strings.ToLower(w)
}
path += w
return path
return path
}).Handle(new(ExampleControllerCustomPath))
return app
@@ -131,7 +132,6 @@ func (c *ExampleControllerCustomPath) GetHelloWorld() interface{} {
return map[string]string{"message": "Hello Iris! CustomPath"}
}
// GetUserBy serves
// Method: GET
// Resource: http://localhost:8080/user/{username:string}

View File

@@ -0,0 +1,24 @@
package main
import (
"github.com/kataras/iris/v12"
)
func main() {
app := iris.New()
app.Get("/", index)
app.Get("/about", about).SetName("about_page")
app.RemoveRoute("about_page")
// http://localhost:8080
// http://localhost:8080/about (Not Found)
app.Listen(":8080")
}
func index(ctx iris.Context) {
ctx.WriteString("Hello, Gophers!")
}
func about(ctx iris.Context) {
ctx.HTML("<h1>About Page</h1>")
}