Merge pull request #142 from Fenny/master

Fix links, supporters and add collapse
This commit is contained in:
Fenny 2020-02-13 20:06:57 -05:00 committed by GitHub
commit 525a845202
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 469 additions and 182 deletions

191
.github/README.md vendored
View File

@ -3,7 +3,7 @@
<img alt="Fiber" height="100" src="https://github.com/gofiber/docs/blob/master/static/logo.svg">
</a>
<br><br>
<!--<a href="https://github.com/gofiber/fiber/blob/master/README.md">
<!--<a href="https://github.com/gofiber/fiber/blob/master/.github/README.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/gb.svg">
</a>-->
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_ru.md">
@ -136,121 +136,136 @@ func main() {
### Routing
```go
func main() {
app := fiber.New()
<details>
<summary>📜 Show code snippet</summary>
```go
func main() {
app := fiber.New()
// GET /john
app.Get("/:name", func(c *fiber.Ctx) {
fmt.Printf("Hello %s!", c.Params("name"))
// => Hello john!
})
// GET /john
app.Get("/:name", func(c *fiber.Ctx) {
fmt.Printf("Hello %s!", c.Params("name"))
// => Hello john!
})
// GET /john
app.Get("/:name/:age?", func(c *fiber.Ctx) {
fmt.Printf("Name: %s, Age: %s", c.Params("name"), c.Params("age"))
// => Name: john, Age:
})
// GET /john
app.Get("/:name/:age?", func(c *fiber.Ctx) {
fmt.Printf("Name: %s, Age: %s", c.Params("name"), c.Params("age"))
// => Name: john, Age:
})
// GET /api/register
app.Get("/api*", func(c *fiber.Ctx) {
fmt.Printf("/api%s", c.Params("*"))
// => /api/register
})
// GET /api/register
app.Get("/api*", func(c *fiber.Ctx) {
fmt.Printf("/api%s", c.Params("*"))
// => /api/register
})
app.Listen(3000)
}
```
app.Listen(3000)
}
```
</summary>
### Middleware
```go
func main() {
app := fiber.New()
<details>
<summary>📜 Show code snippet</summary>
```go
func main() {
app := fiber.New()
// Match any post route
app.Post(func(c *fiber.Ctx) {
user, pass, ok := c.BasicAuth()
if !ok || user != "john" || pass != "doe" {
c.Status(403).Send("Sorry John")
return
}
c.Next()
})
// Match any post route
app.Post(func(c *fiber.Ctx) {
user, pass, ok := c.BasicAuth()
if !ok || user != "john" || pass != "doe" {
c.Status(403).Send("Sorry John")
return
}
c.Next()
})
// Match all routes starting with /api
app.Use("/api", func(c *fiber.Ctx) {
c.Set("Access-Control-Allow-Origin", "*")
c.Set("Access-Control-Allow-Headers", "X-Requested-With")
c.Next()
})
// Match all routes starting with /api
app.Use("/api", func(c *fiber.Ctx) {
c.Set("Access-Control-Allow-Origin", "*")
c.Set("Access-Control-Allow-Headers", "X-Requested-With")
c.Next()
})
// Optional param
app.Post("/api/register", func(c *fiber.Ctx) {
username := c.Body("username")
password := c.Body("password")
// ..
})
// Optional param
app.Post("/api/register", func(c *fiber.Ctx) {
username := c.Body("username")
password := c.Body("password")
// ..
})
app.Listen(3000)
}
```
app.Listen(3000)
}
```
</summary>
### 404 Handling
```go
func main() {
app := fiber.New()
<details>
<summary>📜 Show code snippet</summary>
```go
func main() {
app := fiber.New()
// Serve static files from "public" directory
app.Static("./public")
// Serve static files from "public" directory
app.Static("./public")
// Last middleware
app.Use(func(c *fiber.Ctx) {
c.SendStatus(404) // => 404 "Not Found"
})
// Last middleware
app.Use(func(c *fiber.Ctx) {
c.SendStatus(404) // => 404 "Not Found"
})
app.Listen(3000)
}
```
app.Listen(3000)
}
```
</summary>
### JSON Response
```go
func main() {
app := fiber.New()
<details>
<summary>📜 Show code snippet</summary>
```go
func main() {
app := fiber.New()
type User struct {
Name string `json:"name"`
Age int `json:"age"`
type User struct {
Name string `json:"name"`
Age int `json:"age"`
}
// Serialize JSON
app.Get("/json", func(c *fiber.Ctx) {
c.JSON(&User{"John", 20})
})
app.Listen(3000)
}
// Serialize JSON
app.Get("/json", func(c *fiber.Ctx) {
c.JSON(&User{"John", 20})
})
app.Listen(3000)
}
```
```
</summary>
### Recover
```go
func main() {
app := fiber.New()
<details>
<summary>📜 Show code snippet</summary>
```go
func main() {
app := fiber.New()
app.Get("/json", func(c *fiber.Ctx) {
panic("Something went wrong!")
})
app.Get("/json", func(c *fiber.Ctx) {
panic("Something went wrong!")
})
app.Recover(func(c *fiber.Ctx) {
c.Status(500).Send(c.Error())
})
app.Recover(func(c *fiber.Ctx) {
c.Status(500).Send(c.Error())
})
app.Listen(3000)
}
```
app.Listen(3000)
}
```
</details>
## 💬 Media

49
.github/README_de.md vendored
View File

@ -3,7 +3,7 @@
<img alt="Fiber" height="100" src="https://github.com/gofiber/docs/blob/master/static/logo.svg">
</a>
<br><br>
<a href="https://github.com/gofiber/fiber/blob/master/README.md">
<a href="https://github.com/gofiber/fiber/blob/master/.github/README.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/gb.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_ru.md">
@ -231,6 +231,24 @@ func main() {
}
```
### Recover
```go
func main() {
app := fiber.New()
app.Get("/json", func(c *fiber.Ctx) {
panic("Something went wrong!")
})
app.Recover(func(c *fiber.Ctx) {
c.Status(500).Send(c.Error())
})
app.Listen(3000)
}
```
## 💬 Medien
- [Welcome to Fiber — an Express.js styled web framework written in Go with ❤️](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) _von [Vic Shóstak](https://github.com/koddr), 03 Feb 2020_
@ -244,18 +262,35 @@ Falls du **danke** sagen möchtest und/oder aktiv die Entwicklung von `fiber` f
3. Schreibe eine Rezension auf [Medium](https://medium.com/), [Dev.to](https://dev.to/) oder einem persönlichem Blog.
4. Hilf uns diese `README` und die [API Docs](https://fiber.wiki/) in eine andere Sprache zu übersetzen.
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" style="height: 35px !important;" ></a>
## ☕ Supporters
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" height="100" ></a>
<table>
<tr>
<td align="center">
<a href="https://www.buymeacoffee.com/fenny">
<img src="https://img.buymeacoffee.com/api/?name=ToishY&size=300&bg-image=bmc" width="100px;" style="border-radius:50%"></br>
<b>ToishY</b>
<a href="https://github.com/bihe">
<img src="https://avatars1.githubusercontent.com/u/635852?s=460&v=4" width="75"></br>
<sub><b>HenrikBinggl</b></sub>
</a>
</td>
</td>
<td align="center">
<a href="https://github.com/koddr">
<img src="https://avatars0.githubusercontent.com/u/11155743?s=460&v=4" width="75"></br>
<sub><b>koddr</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/MarvinJWendt">
<img src="https://avatars1.githubusercontent.com/u/31022056?s=460&v=4" width="75"></br>
<sub><b>MarvinJWendt</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/toishy">
<img src="https://avatars1.githubusercontent.com/u/31921460?s=460&v=4" width="75"></br>
<sub><b>ToishY</b></sub>
</a>
</td>
</tr>
</table>

49
.github/README_es.md vendored
View File

@ -3,7 +3,7 @@
<img alt="Fiber" height="100" src="https://github.com/gofiber/docs/blob/master/static/logo.svg">
</a>
<br><br>
<a href="https://github.com/gofiber/fiber/blob/master/README.md">
<a href="https://github.com/gofiber/fiber/blob/master/.github/README.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/gb.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_ru.md">
@ -230,6 +230,24 @@ func main() {
}
```
### Recover
```go
func main() {
app := fiber.New()
app.Get("/json", func(c *fiber.Ctx) {
panic("Something went wrong!")
})
app.Recover(func(c *fiber.Ctx) {
c.Status(500).Send(c.Error())
})
app.Listen(3000)
}
```
## 💬 Medios
- [Bienvenido a Fiber: un marco web con estilo Express.js escrito en Go with ❤️](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) *por [Vic Shóstak](https://github.com/koddr), 03 feb 2020*
@ -243,18 +261,35 @@ Si quiere **agradecer** y/o apoyar el desarrollo activo de la `Fiber`:
3. Escriba una reseña o tutorial en [Medium](https://medium.com/) , [Dev.to](https://dev.to/) o blog personal.
4. Ayúdanos a traducir este `README` y [API Docs](https://fiber.wiki/) a otro idioma.
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" height="100" ></a>
## ☕ Supporters
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" height="100" ></a>
<table>
<tr>
<td align="center">
<a href="https://www.buymeacoffee.com/fenny">
<img src="https://img.buymeacoffee.com/api/?name=ToishY&size=300&bg-image=bmc" width="100px;" style="border-radius:50%"></br>
<b>ToishY</b>
<a href="https://github.com/bihe">
<img src="https://avatars1.githubusercontent.com/u/635852?s=460&v=4" width="75"></br>
<sub><b>HenrikBinggl</b></sub>
</a>
</td>
</td>
<td align="center">
<a href="https://github.com/koddr">
<img src="https://avatars0.githubusercontent.com/u/11155743?s=460&v=4" width="75"></br>
<sub><b>koddr</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/MarvinJWendt">
<img src="https://avatars1.githubusercontent.com/u/31022056?s=460&v=4" width="75"></br>
<sub><b>MarvinJWendt</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/toishy">
<img src="https://avatars1.githubusercontent.com/u/31921460?s=460&v=4" width="75"></br>
<sub><b>ToishY</b></sub>
</a>
</td>
</tr>
</table>

47
.github/README_ja.md vendored
View File

@ -3,7 +3,7 @@
<img alt="Fiber" height="100" src="https://github.com/gofiber/docs/blob/master/static/logo.svg">
</a>
<br><br>
<a href="https://github.com/gofiber/fiber/blob/master/README.md">
<a href="https://github.com/gofiber/fiber/blob/master/.github/README.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/gb.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_ru.md">
@ -230,6 +230,24 @@ func main() {
}
```
### Recover
```go
func main() {
app := fiber.New()
app.Get("/json", func(c *fiber.Ctx) {
panic("Something went wrong!")
})
app.Recover(func(c *fiber.Ctx) {
c.Status(500).Send(c.Error())
})
app.Listen(3000)
}
```
## 💬 メディア
- [ファイバーへようこそ— Go with❤で記述されたExpress.jsスタイルのWebフレームワーク](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) *[ヴィック・ショースタク](https://github.com/koddr) 、2020年2月3日*
@ -247,14 +265,33 @@ func main() {
## ☕ Supporters
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" height="100" ></a>
<table>
<tr>
<td align="center">
<a href="https://www.buymeacoffee.com/fenny">
<img src="https://img.buymeacoffee.com/api/?name=ToishY&size=300&bg-image=bmc" width="100px;" style="border-radius:50%"></br>
<b>ToishY</b>
<a href="https://github.com/bihe">
<img src="https://avatars1.githubusercontent.com/u/635852?s=460&v=4" width="75"></br>
<sub><b>HenrikBinggl</b></sub>
</a>
</td>
</td>
<td align="center">
<a href="https://github.com/koddr">
<img src="https://avatars0.githubusercontent.com/u/11155743?s=460&v=4" width="75"></br>
<sub><b>koddr</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/MarvinJWendt">
<img src="https://avatars1.githubusercontent.com/u/31022056?s=460&v=4" width="75"></br>
<sub><b>MarvinJWendt</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/toishy">
<img src="https://avatars1.githubusercontent.com/u/31921460?s=460&v=4" width="75"></br>
<sub><b>ToishY</b></sub>
</a>
</td>
</tr>
</table>

49
.github/README_ko.md vendored
View File

@ -3,7 +3,7 @@
<img alt="Fiber" height="100" src="https://github.com/gofiber/docs/blob/master/static/logo.svg">
</a>
<br><br>
<a href="https://github.com/gofiber/fiber/blob/master/README.md">
<a href="https://github.com/gofiber/fiber/blob/master/.github/README.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/gb.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_ru.md">
@ -231,6 +231,24 @@ func main() {
}
```
### Recover
```go
func main() {
app := fiber.New()
app.Get("/json", func(c *fiber.Ctx) {
panic("Something went wrong!")
})
app.Recover(func(c *fiber.Ctx) {
c.Status(500).Send(c.Error())
})
app.Listen(3000)
}
```
## 💬 미디어
- [Welcome to Fiber — an Express.js styled web framework written in Go with ❤️](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) _by [Vic Shóstak](https://github.com/koddr), 03 Feb 2020_
@ -244,18 +262,35 @@ func main() {
3. [Medium](https://medium.com/), [Dev.to](https://dev.to/) 또는 개인 블로그에 리뷰 또는 튜토리얼을 작성하세요.
4. `README` 와 [API 문서](https://fiber.wiki/)를 다른 언어로 번역하는 것을 도와주세요.
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" height="100" ></a>
## ☕ Supporters
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" height="100" ></a>
<table>
<tr>
<td align="center">
<a href="https://www.buymeacoffee.com/fenny">
<img src="https://img.buymeacoffee.com/api/?name=ToishY&size=300&bg-image=bmc" width="100px;" style="border-radius:50%"></br>
<b>ToishY</b>
<a href="https://github.com/bihe">
<img src="https://avatars1.githubusercontent.com/u/635852?s=460&v=4" width="75"></br>
<sub><b>HenrikBinggl</b></sub>
</a>
</td>
</td>
<td align="center">
<a href="https://github.com/koddr">
<img src="https://avatars0.githubusercontent.com/u/11155743?s=460&v=4" width="75"></br>
<sub><b>koddr</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/MarvinJWendt">
<img src="https://avatars1.githubusercontent.com/u/31022056?s=460&v=4" width="75"></br>
<sub><b>MarvinJWendt</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/toishy">
<img src="https://avatars1.githubusercontent.com/u/31921460?s=460&v=4" width="75"></br>
<sub><b>ToishY</b></sub>
</a>
</td>
</tr>
</table>

49
.github/README_pt.md vendored
View File

@ -3,7 +3,7 @@
<img alt="Fiber" height="100" src="https://github.com/gofiber/docs/blob/master/static/logo.svg">
</a>
<br><br>
<a href="https://github.com/gofiber/fiber/blob/master/README.md">
<a href="https://github.com/gofiber/fiber/blob/master/.github/README.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/gb.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_ru.md">
@ -231,6 +231,24 @@ func main() {
}
```
### Recover
```go
func main() {
app := fiber.New()
app.Get("/json", func(c *fiber.Ctx) {
panic("Something went wrong!")
})
app.Recover(func(c *fiber.Ctx) {
c.Status(500).Send(c.Error())
})
app.Listen(3000)
}
```
## 💬 Mídia
- [Bem-vindo ao Fiber — uma estrutura da Web com estilo Express.js, escrita em Go com ❤️](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) _por [Vic Shóstak](https://github.com/koddr), 03 fev 2020_
@ -244,18 +262,35 @@ Se você quer **agradecer** e/ou apoiar o desenvolvimento ativo do `Fiber`:
3. Escreva um review ou tutorial no [Medium](https://medium.com/), [Dev.to](https://dev.to/) ou blog pessoal.
4. Nos ajude a traduzir esses `README` e a [documentação da API](https://fiber.wiki/) para outros idiomas.
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" height="100" ></a>
## ☕ Supporters
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" height="100" ></a>
<table>
<tr>
<td align="center">
<a href="https://www.buymeacoffee.com/fenny">
<img src="https://img.buymeacoffee.com/api/?name=ToishY&size=300&bg-image=bmc" width="100px;" style="border-radius:50%"></br>
<b>ToishY</b>
<a href="https://github.com/bihe">
<img src="https://avatars1.githubusercontent.com/u/635852?s=460&v=4" width="75"></br>
<sub><b>HenrikBinggl</b></sub>
</a>
</td>
</td>
<td align="center">
<a href="https://github.com/koddr">
<img src="https://avatars0.githubusercontent.com/u/11155743?s=460&v=4" width="75"></br>
<sub><b>koddr</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/MarvinJWendt">
<img src="https://avatars1.githubusercontent.com/u/31022056?s=460&v=4" width="75"></br>
<sub><b>MarvinJWendt</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/toishy">
<img src="https://avatars1.githubusercontent.com/u/31921460?s=460&v=4" width="75"></br>
<sub><b>ToishY</b></sub>
</a>
</td>
</tr>
</table>

49
.github/README_ru.md vendored
View File

@ -3,7 +3,7 @@
<img alt="Fiber" height="100" src="https://github.com/gofiber/docs/blob/master/static/logo.svg">
</a>
<br><br>
<a href="https://github.com/gofiber/fiber/blob/master/README.md">
<a href="https://github.com/gofiber/fiber/blob/master/.github/README.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/gb.svg">
</a>
<!--<a href="https://github.com/gofiber/fiber/blob/master/.github/README_ru.md">
@ -232,6 +232,24 @@ func main() {
}
```
### Recover
```go
func main() {
app := fiber.New()
app.Get("/json", func(c *fiber.Ctx) {
panic("Something went wrong!")
})
app.Recover(func(c *fiber.Ctx) {
c.Status(500).Send(c.Error())
})
app.Listen(3000)
}
```
## 💬 Медиа
- [Welcome to Fiber — an Express.js styled web framework written in Go with ❤️](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) *[Vic Shóstak](https://github.com/koddr), 3 февраля 2020 г.*
@ -245,18 +263,35 @@ func main() {
3. Сделайте обзор фреймворка на [Medium](https://medium.com/), [Dev.to](https://dev.to/) или в личном блоге.
4. Помогите нам перевести `README` и [API](https://fiber.wiki/) на другой язык.
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" height="100" ></a>
## ☕ Supporters
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" height="100" ></a>
<table>
<tr>
<td align="center">
<a href="https://www.buymeacoffee.com/fenny">
<img src="https://img.buymeacoffee.com/api/?name=ToishY&size=300&bg-image=bmc" width="100px;" style="border-radius:50%"></br>
<b>ToishY</b>
<a href="https://github.com/bihe">
<img src="https://avatars1.githubusercontent.com/u/635852?s=460&v=4" width="75"></br>
<sub><b>HenrikBinggl</b></sub>
</a>
</td>
</td>
<td align="center">
<a href="https://github.com/koddr">
<img src="https://avatars0.githubusercontent.com/u/11155743?s=460&v=4" width="75"></br>
<sub><b>koddr</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/MarvinJWendt">
<img src="https://avatars1.githubusercontent.com/u/31022056?s=460&v=4" width="75"></br>
<sub><b>MarvinJWendt</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/toishy">
<img src="https://avatars1.githubusercontent.com/u/31921460?s=460&v=4" width="75"></br>
<sub><b>ToishY</b></sub>
</a>
</td>
</tr>
</table>

View File

@ -3,7 +3,7 @@
<img alt="Fiber" height="100" src="https://github.com/gofiber/docs/blob/master/static/logo.svg">
</a>
<br><br>
<a href="https://github.com/gofiber/fiber/blob/master/README.md">
<a href="https://github.com/gofiber/fiber/blob/master/.github/README.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/gb.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_ru.md">
@ -157,75 +157,105 @@ func main() {
### 中间件
```go
func main() {
app := fiber.New()
<details>
<summary>📜 Show code snippet</summary>
```go
func main() {
app := fiber.New()
// Match any post route
app.Post(func(c *fiber.Ctx) {
user, pass, ok := c.BasicAuth()
if !ok || user != "john" || pass != "doe" {
c.Status(403).Send("Sorry John")
return
}
c.Next()
})
// Match any post route
app.Post(func(c *fiber.Ctx) {
user, pass, ok := c.BasicAuth()
if !ok || user != "john" || pass != "doe" {
c.Status(403).Send("Sorry John")
return
}
c.Next()
})
// Match all routes starting with /api
app.Use("/api", func(c *fiber.Ctx) {
c.Set("Access-Control-Allow-Origin", "*")
c.Set("Access-Control-Allow-Headers", "X-Requested-With")
c.Next()
})
// Match all routes starting with /api
app.Use("/api", func(c *fiber.Ctx) {
c.Set("Access-Control-Allow-Origin", "*")
c.Set("Access-Control-Allow-Headers", "X-Requested-With")
c.Next()
})
// Optional param
app.Post("/api/register", func(c *fiber.Ctx) {
username := c.Body("username")
password := c.Body("password")
// ..
})
// Optional param
app.Post("/api/register", func(c *fiber.Ctx) {
username := c.Body("username")
password := c.Body("password")
// ..
})
app.Listen(3000)
}
```
app.Listen(3000)
}
```
</summary>
### 404处理
```go
func main() {
app := fiber.New()
<details>
<summary>📜 Show code snippet</summary>
```go
func main() {
app := fiber.New()
// Serve static files from "public" directory
app.Static("./public")
// Serve static files from "public" directory
app.Static("./public")
// Last middleware
app.Use(func(c *fiber.Ctx) {
c.SendStatus(404) // => 404 "Not Found"
})
// Last middleware
app.Use(func(c *fiber.Ctx) {
c.SendStatus(404) // => 404 "Not Found"
})
app.Listen(3000)
}
```
app.Listen(3000)
}
```
</summary>
### JSON响应
```go
func main() {
app := fiber.New()
<details>
<summary>📜 Show code snippet</summary>
```go
func main() {
app := fiber.New()
type User struct {
Name string `json:"name"`
Age int `json:"age"`
type User struct {
Name string `json:"name"`
Age int `json:"age"`
}
// Serialize JSON
app.Get("/json", func(c *fiber.Ctx) {
c.JSON(&User{"John", 20})
})
app.Listen(3000)
}
```
</summary>
// Serialize JSON
app.Get("/json", func(c *fiber.Ctx) {
c.JSON(&User{"John", 20})
})
### Recover
app.Listen(3000)
}
```
<details>
<summary>📜 Show code snippet</summary>
```go
func main() {
app := fiber.New()
app.Get("/json", func(c *fiber.Ctx) {
panic("Something went wrong!")
})
app.Recover(func(c *fiber.Ctx) {
c.Status(500).Send(c.Error())
})
app.Listen(3000)
}
```
</details>
## 💬 媒体
@ -238,9 +268,39 @@ func main() {
1. 将[GitHub Star](https://github.com/gofiber/fiber/stargazers)添加到项目中。
2. [在Twitter上](https://twitter.com/intent/tweet?text=%F0%9F%9A%80%20Fiber%20%E2%80%94%20is%20an%20Express.js%20inspired%20web%20framework%20build%20on%20Fasthttp%20for%20%23Go%20https%3A%2F%2Fgithub.com%2Fgofiber%2Ffiber)发布有关项目[的推文](https://twitter.com/intent/tweet?text=%F0%9F%9A%80%20Fiber%20%E2%80%94%20is%20an%20Express.js%20inspired%20web%20framework%20build%20on%20Fasthttp%20for%20%23Go%20https%3A%2F%2Fgithub.com%2Fgofiber%2Ffiber) 。
3. 在[Medium](https://medium.com/) [Dev.to](https://dev.to/)或个人博客上写评论或教程。
4. 帮助我们将此`README` [文件](https://fiber.wiki/)和[API文档](https://fiber.wiki/)翻译成另一种语言。
4. 帮助我们将此`README` [文件](https://fiber.wiki/)和[API文档](https://fiber.wiki/)翻译成另一种语言
## ☕ Supporters
<a href="https://www.buymeacoffee.com/fenny" target="_blank"><img src="https://github.com/gofiber/docs/blob/master/static/buy-morning-coffee-3x.gif" alt="Buy Me A Coffee" height="100" ></a>
<table>
<tr>
<td align="center">
<a href="https://github.com/bihe">
<img src="https://avatars1.githubusercontent.com/u/635852?s=460&v=4" width="75"></br>
<sub><b>HenrikBinggl</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/koddr">
<img src="https://avatars0.githubusercontent.com/u/11155743?s=460&v=4" width="75"></br>
<sub><b>koddr</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/MarvinJWendt">
<img src="https://avatars1.githubusercontent.com/u/31022056?s=460&v=4" width="75"></br>
<sub><b>MarvinJWendt</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/toishy">
<img src="https://avatars1.githubusercontent.com/u/31921460?s=460&v=4" width="75"></br>
<sub><b>ToishY</b></sub>
</a>
</td>
</tr>
</table>
### ⭐️ 星星