-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Description
Question description
I'm trying to create a dynamic router where user pass the httpMethod, router and handler ( prevealy defined ). So user will make a request
POST /route
{
"method": "POST",
"handler": "Ping",
"path": "/ping"
}
and a new /ping route will be added.
if user wants to change the route he do:
PUT /route
{
"method": "GET",
"handler": "Ping",
"path": "/ping"
}
or delete the route:
DELETE /route
{
"method": "POST",
"handler": "Ping",
"path": "/ping"
}
Code snippet
I've tried the following:
package main
import "github.com/gofiber/fiber"
func main() {
app := fiber.New()
app.Get("/add", func(c *fiber.Ctx) {
app.Get("/ping", Ping)
m := make(map[string]string)
m["message"] = "Ping Added!"
c.JSON(m)
})
app.Listen("8080")
}
// Ping return a Pong message
func Ping(c *fiber.Ctx) {
m := make(map[string]string)
m["message"] = "Pong!"
c.JSON(m)
}Reactions are currently unavailable