2018-02-21 10:27:01 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/kataras/iris"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := iris.New()
|
|
|
|
|
|
|
|
// this works as expected now,
|
|
|
|
// will handle *all* expect DELETE requests, even if there is no routes
|
|
|
|
app.Get("/action/{p}", h)
|
|
|
|
|
2018-02-21 12:48:09 +01:00
|
|
|
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed))
|
2018-02-21 10:27:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func h(ctx iris.Context) {
|
2018-02-21 12:48:09 +01:00
|
|
|
ctx.Writef("[%s] %s : Parameter = `%s`", ctx.Method(), ctx.Path(), ctx.Params().Get("p"))
|
2018-02-21 10:27:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func fallbackHandler(ctx iris.Context) {
|
|
|
|
if ctx.Method() == "DELETE" {
|
|
|
|
ctx.Next()
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Writef("[%s] %s : From fallback handler", ctx.Method(), ctx.Path())
|
|
|
|
}
|