1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-21 05:52:45 +00:00

Update README.md

This commit is contained in:
Vic Shóstak 2020-03-07 17:34:42 +03:00 committed by GitHub
parent 778953db3c
commit 79675954af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

138
.github/README.md vendored
View File

@ -4,37 +4,37 @@
</a>
<br>
<!--<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">
<img height="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/en.svg">
</a>-->
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_ru.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/ru.svg">
<img height="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/ru.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_es.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/es.svg">
<img height="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/es.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_ja.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/jp.svg">
<img height="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/jp.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_pt.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/pt.svg">
<img height="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/pt.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_zh-CN.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/cn.svg">
<img height="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/ch.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_de.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/de.svg">
<img height="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/de.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_ko.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/kr.svg">
<img height="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/ko.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_fr.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/fr.svg">
<img height="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/fr.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_tr.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/tr.svg">
<img height="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/tr.svg">
</a>
<a href="https://github.com/gofiber/fiber/blob/master/.github/README_id.md">
<img height="20px" src="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.6/flags/4x3/id.svg">
<img height="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/id.svg">
</a>
<br><br>
<a href="https://github.com/gofiber/fiber/releases">
@ -129,6 +129,12 @@ Listed below are some of the common examples. If you want to see more code examp
### Routing
Docs:
- 📖 https://fiber.wiki/#basic-routing
Example:
```go
func main() {
app := fiber.New()
@ -156,7 +162,13 @@ func main() {
```
### Serve static files
https://fiber.wiki/application#static
Docs:
- 📖 https://fiber.wiki/application#static
Example:
```go
func main() {
app := fiber.New()
@ -177,8 +189,14 @@ func main() {
```
### Middleware & Next
https://fiber.wiki/routing#middleware
https://fiber.wiki/context#next
Docs:
- 📖 https://fiber.wiki/routing#middleware
- 📖 https://fiber.wiki/context#next
Example:
```go
func main() {
app := fiber.New()
@ -209,16 +227,22 @@ func main() {
<summary>📚 Show more code examples</summary>
### Template engines
https://fiber.wiki/application#settings
https://fiber.wiki/context#render
Docs:
- 📖 https://fiber.wiki/application#settings
- 📖 https://fiber.wiki/context#render
Supported engines:
- [html](https://golang.org/pkg/html/template/)
- [amber](https://github.com/eknkc/amber)
- [handlebars](https://github.com/aymerick/raymond)
- [mustache](https://github.com/cbroglie/mustache)
- [pug](https://github.com/Joker/jade)
Example:
```go
func main() {
// You can setup template engine before initiation app:
@ -246,7 +270,13 @@ func main() {
```
### Grouping routes into chains
https://fiber.wiki/application#group
Docs:
- 📖 https://fiber.wiki/application#group
Example:
```go
func main() {
app := fiber.New()
@ -269,7 +299,13 @@ func main() {
```
### Middleware logger
https://fiber.wiki/middleware#logger
Docs:
- 📖 https://fiber.wiki/middleware#logger
Example:
```go
import (
"github.com/gofiber/fiber"
@ -293,9 +329,14 @@ func main() {
```
### Cross-Origin Resource Sharing (CORS)
https://fiber.wiki/middleware#cors
[CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) is a mechanism that uses additional HTTP headers to tell browsers to give a web application running at one origin, access to selected resources from a different origin. A web application executes a cross-origin HTTP request when it requests a resource that has a different origin (domain, protocol, or port) from its own.
Docs:
- 📖 https://fiber.wiki/middleware#cors
> [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) is a mechanism that uses additional HTTP headers to tell browsers to give a web application running at one origin, access to selected resources from a different origin. A web application executes a cross-origin HTTP request when it requests a resource that has a different origin (domain, protocol, or port) from its own.
Example:
```go
import (
@ -310,7 +351,7 @@ func main() {
app.Use(middleware.CORS())
app.Get("/", func(c *fiber.Ctx) {
c.Send("CORS is enabled!")
c.Send("CORS is enabled!")
})
app.Listen(3000)
@ -325,6 +366,12 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
### Custom 404 response
Docs:
- 📖 https://fiber.wiki/application#http-methods
Example:
```go
func main() {
app := fiber.New()
@ -341,7 +388,8 @@ func main() {
// Last middleware to match anything
app.Use(func(c *fiber.Ctx) {
c.SendStatus(404) // => 404 "Not Found"
c.SendStatus(404)
// => 404 "Not Found"
})
app.Listen(3000)
@ -349,7 +397,13 @@ func main() {
```
### JSON Response
https://fiber.wiki/context#json
Docs:
- 📖 https://fiber.wiki/context#json
Example:
```go
type User struct {
Name string `json:"name"`
@ -361,15 +415,15 @@ func main() {
app.Get("/user", func(c *fiber.Ctx) {
c.JSON(&User{"John", 20})
// {"name":"John", "age":20}
// => {"name":"John", "age":20}
})
app.Get("/json", func(c *fiber.Ctx) {
c.JSON(&fiber.Map{
"success": true,
"message": "Hi John!",
c.JSON(fiber.Map{
"success": true,
"message": "Hi John!",
})
// {"success":true, "message":"Hi John!"}
// => {"success":true, "message":"Hi John!"}
})
app.Listen(3000)
@ -377,7 +431,13 @@ func main() {
```
### WebSocket support
https://fiber.wiki/application#websocket
Docs:
- 📖 https://fiber.wiki/application#websocket
Example:
```go
func main() {
app := fiber.New()
@ -406,7 +466,13 @@ func main() {
```
### Recover middleware
https://fiber.wiki/middleware#recover
Docs:
- 📖 https://fiber.wiki/middleware#recover
Example:
```go
package main
@ -455,12 +521,6 @@ If you want to say **thank you** and/or support the active development of `Fiber
<table>
<tr>
<td align="center">
<a href="https://github.com/gofiber/fiber">
<img src="https://i.stack.imgur.com/frlIf.png" width="100px"></br>
<sub><b>JustDave</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/bihe">
<img src="https://avatars1.githubusercontent.com/u/635852?s=460&v=4" width="100px"></br>
@ -485,6 +545,12 @@ If you want to say **thank you** and/or support the active development of `Fiber
<sub><b>ToishY</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/gofiber/fiber">
<img src="https://i.stack.imgur.com/frlIf.png" width="100px"></br>
<sub><b>JustDave</b></sub>
</a>
</td>
</tr>
</table>