Not able to use URI !!! Help #2972
Answered
by
aldas
m-rishikesh
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
aldas
May 14, 2026
Replies: 1 comment 1 reply
-
|
try this package main
import (
"log/slog"
"github.com/labstack/echo/v5"
)
func main() {
e := echo.New()
ri := e.GET("/users/:id", func(c *echo.Context) error {
return c.String(200, "Hello, World!")
})
uri := ri.Reverse(123)
slog.Info("Reverse route URI generated", "uri", uri)
}or package main
import (
"log/slog"
"net/http"
"github.com/labstack/echo/v5"
)
func main() {
e := echo.New()
ri, _ := e.AddRoute(echo.Route{
Method: http.MethodGet,
Path: "/users/:id",
Name: "get_user_by_id",
Handler: func(c *echo.Context) error {
return c.String(200, "Hello, World!")
},
})
uri := ri.Reverse(123)
uri2, _ := e.Router().Routes().Reverse("get_user_by_id", 100)
slog.Info("Reverse route URI generated", "uri", uri, "uri2", uri2)
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
m-rishikesh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


try this
or