From cc6efaba9afc710be3472cbfefe49f76e64b5af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muhammed=20Efe=20=C3=87etin?= Date: Tue, 18 Jan 2022 14:20:22 +0300 Subject: [PATCH] Add docs for Route() method. --- api/app.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/api/app.md b/api/app.md index aec203599b4..59525a79eeb 100644 --- a/api/app.md +++ b/api/app.md @@ -235,6 +235,31 @@ func main() { } ``` +## Route + +You can define routes with a common prefix inside the common function. + +**Signature** + +```go +func (app *App) Route(prefix string, fn func(router Router), name ...string) Router +``` + +**Example** + +```go +func main() { + app := fiber.New() + + app.Route("/test", func(api fiber.Router) { + api.Get("/foo", handler).Name("foo") // /test/foo (name: test.foo) + api.Get("/bar", handler).Name("bar") // /test/bar (name: test.bar) + }, "test.") + + log.Fatal(app.Listen(":3000")) +} +``` + ## Server Server returns the underlying [fasthttp server](https://godoc.org/github.com/valyala/fasthttp#Server)