iris
iris copied to clipboard
Is there a way to dynamically add routes?
I need to serve a static directory which passed by users after the program starts, I tried CreateRoutes
but it didn't work.
Is there any way to achieve this requirement?
it works with below code
app.Get("/mapping/{name}/{dir}", func(ctx iris.Context) {
app.HandleDir("/static/" + ctx.Params().Get("name"), iris.Dir("../" + ctx.Params().Get("dir")), iris.DirOptions{
ShowList: true,
SPA: false,
})
app.RefreshRouter()
ctx.Text("OK")
})
another question is: how can I delete the routes? There is a method named SetStatusOffline
, but it doesn't delete the route.
@kataras Do you have time to look at my questions? 😃
Yes @tuhao1020 through the AddRouteUnsafe
. Example can be found at the configuration.go file
@kataras now I need a function like RemoveRoute(path string)
😄