Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doc for GetRouteURL #249

Merged
merged 4 commits into from Mar 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions api/ctx.md
Expand Up @@ -1302,6 +1302,31 @@ app.Get("/back", func(c *fiber.Ctx) error {
```
{% endcode %}

## GetRouteURL

Get URI of route by route name and parameters
sujit-baniya marked this conversation as resolved.
Show resolved Hide resolved

{% code title="Signature" %}
```go
func (c *Ctx) GetRouteURL(routeName string, params Map) (string, error)
```
{% endcode %}

{% code title="Example" %}
```go
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Home page")
}).Name("Home")
app.Get("/user/:id", func(c *fiber.Ctx) error {
return c.SendString(c.Params("id"))
}).Name("user.show")
app.Get("/test", func(c *fiber.Ctx) error {
location, _ := c.GetRouteURL("user.show", fiber.Map{"id": 1})
return c.SendString(location)
})
sujit-baniya marked this conversation as resolved.
Show resolved Hide resolved
```
{% endcode %}

## Render

Renders a view with data and sends a `text/html` response. By default `Render` uses the default [**Go Template engine**](https://golang.org/pkg/html/template/). If you want to use another View engine, please take a look at our [**Template middleware**](https://github.com/gofiber/template).
Expand Down