Is there a way to modify a route while server is running ?
I'm planing to create a interface to developers build our own API from "blocks" and I need a way to dynamically Add, Remove or Modify a route on-the-fly, I tested many web frameworks in Go and Javascript and always has a way to create a route but never a way to remove...
There is a way to dynamically add a new route on-the-fly see it:
package main
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
// Echo instance
e := echo.New()
// Middleware
e.Use(middleware.Logger())
e.Use(middleware.Recover())
// Routes
e.GET("/add", func(c echo.Context) error {
e.GET("/ping", Ping)
return c.String(http.StatusOK, "Added Ping!")
})
// Start server
e.Logger.Fatal(e.Start(":8080"))
}
// Ping ...
func Ping(c echo.Context) error {
return c.String(http.StatusOK, "Pong!")
}
Currently using Echo v4.1.16
Refs: #1026 #1612
Isn't that already answered in #1612? The same restrictions still apply.
So short answer is: No, routes cannot be modified after starting the server and the routing tree has been built.
Most helpful comment
Isn't that already answered in #1612? The same restrictions still apply.
So short answer is: No, routes cannot be modified after starting the server and the routing tree has been built.