2018-02-21 10:27:01 +01:00
|
|
|
package main
|
|
|
|
|
2018-02-23 03:06:05 +01:00
|
|
|
import "github.com/kataras/iris"
|
2018-02-21 10:27:01 +01:00
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := iris.New()
|
|
|
|
|
|
|
|
// this works as expected now,
|
2018-02-23 03:06:05 +01:00
|
|
|
// will handle *all* expect DELETE requests, even if there is no routes.
|
2018-02-21 10:27:01 +01:00
|
|
|
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) {
|
2018-02-23 03:25:12 +01:00
|
|
|
if ctx.Method() == iris.MethodDelete {
|
2018-02-23 03:06:05 +01:00
|
|
|
ctx.NextOrNotFound()
|
2018-02-21 10:27:01 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Writef("[%s] %s : From fallback handler", ctx.Method(), ctx.Path())
|
|
|
|
}
|