Skip to content

Commit

Permalink
Add docs for Name method.
Browse files Browse the repository at this point in the history
  • Loading branch information
efectn committed Dec 18, 2021
1 parent 421b355 commit 88c1daf
Showing 1 changed file with 118 additions and 0 deletions.
118 changes: 118 additions & 0 deletions api/app.md
Expand Up @@ -313,6 +313,124 @@ func main() {
```
{% endcode %}

## Name

This method assigns the name of latest created route.

{% code title="Signature" %}
```go
func (app *App) Name(name string) Router
```
{% endcode %}

{% code title="Example" %}
```go
var handler = func(c *fiber.Ctx) error { return nil }
func main() {
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) error {
...
})
app.Name("index")
app.Get("/doe", func(c *fiber.Ctx) error {
...
}).Name("home")
app.Trace("/tracer", func(c *fiber.Ctx) error {
...
}).Name("tracert")
app.Delete("/delete", func(c *fiber.Ctx) error {
...
}).Name("delete")
a := app.Group("/a")
a.Name("fd.")
a.Get("/test", func(c *fiber.Ctx) error {
...
}).Name("test")
data, _ := json.MarshalIndent(app.Stack(), "", " ")
fmt.Print(string(data))
app.Listen(":3000")
}
```
{% endcode %}

{% code title="Result" %}
```javascript
[
[
{
"method": "GET",
"name": "index",
"path": "/",
"params": null
},
{
"method": "GET",
"name": "home",
"path": "/doe",
"params": null
},
{
"method": "GET",
"name": "fd.test",
"path": "/a/test",
"params": null
}
],
[
{
"method": "HEAD",
"name": "",
"path": "/",
"params": null
},
{
"method": "HEAD",
"name": "",
"path": "/doe",
"params": null
},
{
"method": "HEAD",
"name": "",
"path": "/a/test",
"params": null
}
],
null,
null,
[
{
"method": "DELETE",
"name": "delete",
"path": "/delete",
"params": null
}
],
null,
null,
[
{
"method": "TRACE",
"name": "tracert",
"path": "/tracer",
"params": null
}
],
null
]
```
{% endcode %}

## Config

Config returns the app config as value \( read-only \).
Expand Down

0 comments on commit 88c1daf

Please sign in to comment.