Skip to content

Commit

Permalink
Add route naming feature. (#1650)
Browse files Browse the repository at this point in the history
* Add route naming feature.

* Update basicauth_test.go

* Fix gosec issues.

* Change RoutaName -> Name

* Fix race conditions.

* Update READMEs.
  • Loading branch information
efectn committed Dec 28, 2021
1 parent 03c9598 commit 68d3b77
Show file tree
Hide file tree
Showing 24 changed files with 600 additions and 3 deletions.
30 changes: 30 additions & 0 deletions .github/README.md
Expand Up @@ -191,6 +191,36 @@ func main() {

```

#### 📖 [**Route Naming**](https://docs.gofiber.io/api/app#name)

```go
func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
msg := fmt.Sprintf("%s", c.Params("*"))
return c.SendString(msg) // => ✋ register
}).Name("api")

data, _ := json.MarshalIndent(app.GetRoute("api"), "", " ")
fmt.Print(string(data))
// Prints:
// {
// "method": "GET",
// "name": "api",
// "path": "/api/*",
// "params": [
// "*1"
// ]
// }


log.Fatal(app.Listen(":3000"))
}

```

#### 📖 [**Serving Static Files**](https://docs.gofiber.io/api/app#static)

```go
Expand Down
30 changes: 30 additions & 0 deletions .github/README_de.md
Expand Up @@ -189,6 +189,36 @@ func main() {

```

#### 📖 [**Route Naming**](https://docs.gofiber.io/api/app#name)

```go
func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
msg := fmt.Sprintf("%s", c.Params("*"))
return c.SendString(msg) // => ✋ register
}).Name("api")

data, _ := json.MarshalIndent(app.GetRoute("api"), "", " ")
fmt.Print(string(data))
// Prints:
// {
// "method": "GET",
// "name": "api",
// "path": "/api/*",
// "params": [
// "*1"
// ]
// }


log.Fatal(app.Listen(":3000"))
}

```

#### 📖 [**Serving Static Files**](https://docs.gofiber.io/api/app#static)

```go
Expand Down
30 changes: 30 additions & 0 deletions .github/README_es.md
Expand Up @@ -189,6 +189,36 @@ func main() {

```

#### 📖 [**Route Naming**](https://docs.gofiber.io/api/app#name)

```go
func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
msg := fmt.Sprintf("%s", c.Params("*"))
return c.SendString(msg) // => ✋ register
}).Name("api")

data, _ := json.MarshalIndent(app.GetRoute("api"), "", " ")
fmt.Print(string(data))
// Prints:
// {
// "method": "GET",
// "name": "api",
// "path": "/api/*",
// "params": [
// "*1"
// ]
// }


log.Fatal(app.Listen(":3000"))
}

```

#### 📖 [**Sirviendo Archivos Estáticos**](https://docs.gofiber.io/api/app#static)

```go
Expand Down
35 changes: 35 additions & 0 deletions .github/README_fa.md
Expand Up @@ -240,6 +240,41 @@ func main() {

</div>

<div dir="ltr" >

#### 📖 [**Route Naming**](https://docs.gofiber.io/api/app#name)

```go
func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
msg := fmt.Sprintf("%s", c.Params("*"))
return c.SendString(msg) // => ✋ register
}).Name("api")

data, _ := json.MarshalIndent(app.GetRoute("api"), "", " ")
fmt.Print(string(data))
// Prints:
// {
// "method": "GET",
// "name": "api",
// "path": "/api/*",
// "params": [
// "*1"
// ]
// }


log.Fatal(app.Listen(":3000"))
}

```

</div>


#### 📖 [**Serving Static Files**](https://docs.gofiber.io/api/app#static)

<div dir="ltr">
Expand Down
30 changes: 30 additions & 0 deletions .github/README_fr.md
Expand Up @@ -191,6 +191,36 @@ func main() {

```

#### 📖 [**Route Naming**](https://docs.gofiber.io/api/app#name)

```go
func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
msg := fmt.Sprintf("%s", c.Params("*"))
return c.SendString(msg) // => ✋ register
}).Name("api")

data, _ := json.MarshalIndent(app.GetRoute("api"), "", " ")
fmt.Print(string(data))
// Prints:
// {
// "method": "GET",
// "name": "api",
// "path": "/api/*",
// "params": [
// "*1"
// ]
// }


log.Fatal(app.Listen(":3000"))
}

```

#### 📖 [**Serving Static Files**](https://docs.gofiber.io/api/app#static)

```go
Expand Down
34 changes: 34 additions & 0 deletions .github/README_he.md
Expand Up @@ -246,6 +246,40 @@ func main() {

<div dir="rtl">

#### 📖 [**Route Naming**](https://docs.gofiber.io/api/app#name)

</div>

```go
func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
msg := fmt.Sprintf("%s", c.Params("*"))
return c.SendString(msg) // => ✋ register
}).Name("api")

data, _ := json.MarshalIndent(app.GetRoute("api"), "", " ")
fmt.Print(string(data))
// Prints:
// {
// "method": "GET",
// "name": "api",
// "path": "/api/*",
// "params": [
// "*1"
// ]
// }


log.Fatal(app.Listen(":3000"))
}

```

<div dir="rtl">

#### 📖 [**Serving Static Files**](https://docs.gofiber.io/api/app#static)

</div>
Expand Down
30 changes: 30 additions & 0 deletions .github/README_id.md
Expand Up @@ -191,6 +191,36 @@ func main() {

```

#### 📖 [**Route Naming**](https://docs.gofiber.io/api/app#name)

```go
func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
msg := fmt.Sprintf("%s", c.Params("*"))
return c.SendString(msg) // => ✋ register
}).Name("api")

data, _ := json.MarshalIndent(app.GetRoute("api"), "", " ")
fmt.Print(string(data))
// Prints:
// {
// "method": "GET",
// "name": "api",
// "path": "/api/*",
// "params": [
// "*1"
// ]
// }


log.Fatal(app.Listen(":3000"))
}

```

#### 📖 [**Serving File Static**](https://docs.gofiber.io/api/app#static)

```go
Expand Down
30 changes: 30 additions & 0 deletions .github/README_it.md
Expand Up @@ -190,6 +190,36 @@ func main() {

```

#### 📖 [**Route Naming**](https://docs.gofiber.io/api/app#name)

```go
func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
msg := fmt.Sprintf("%s", c.Params("*"))
return c.SendString(msg) // => ✋ register
}).Name("api")

data, _ := json.MarshalIndent(app.GetRoute("api"), "", " ")
fmt.Print(string(data))
// Prints:
// {
// "method": "GET",
// "name": "api",
// "path": "/api/*",
// "params": [
// "*1"
// ]
// }


log.Fatal(app.Listen(":3000"))
}

```

#### 📖 [**Servire File Statici**](https://docs.gofiber.io/api/app#static)

```go
Expand Down
30 changes: 30 additions & 0 deletions .github/README_ja.md
Expand Up @@ -194,6 +194,36 @@ func main() {

```

#### 📖 [**Route Naming**](https://docs.gofiber.io/api/app#name)

```go
func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
msg := fmt.Sprintf("%s", c.Params("*"))
return c.SendString(msg) // => ✋ register
}).Name("api")

data, _ := json.MarshalIndent(app.GetRoute("api"), "", " ")
fmt.Print(string(data))
// Prints:
// {
// "method": "GET",
// "name": "api",
// "path": "/api/*",
// "params": [
// "*1"
// ]
// }


log.Fatal(app.Listen(":3000"))
}

```

#### 📖 [**静的ファイルの提供**](https://docs.gofiber.io/api/app#static)

```go
Expand Down
30 changes: 30 additions & 0 deletions .github/README_ko.md
Expand Up @@ -195,6 +195,36 @@ func main() {

```

#### 📖 [**Route Naming**](https://docs.gofiber.io/api/app#name)

```go
func main() {
app := fiber.New()

// GET /api/register
app.Get("/api/*", func(c *fiber.Ctx) error {
msg := fmt.Sprintf("%s", c.Params("*"))
return c.SendString(msg) // => ✋ register
}).Name("api")

data, _ := json.MarshalIndent(app.GetRoute("api"), "", " ")
fmt.Print(string(data))
// Prints:
// {
// "method": "GET",
// "name": "api",
// "path": "/api/*",
// "params": [
// "*1"
// ]
// }


log.Fatal(app.Listen(":3000"))
}

```

#### 📖 [**Serving Static Files**](https://docs.gofiber.io/api/app#static)

```go
Expand Down

0 comments on commit 68d3b77

Please sign in to comment.