Skip to content

Commit 58a7511

Browse files
Add docs from gofiber/fiber@9463a8f
1 parent 2bec7a7 commit 58a7511

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1580
-1532
lines changed

docs/core/api/app.md

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ func (app *App) MountPath() string
4343

4444
```go title="Examples"
4545
func main() {
46-
app := fiber.New()
47-
one := fiber.New()
48-
two := fiber.New()
49-
three := fiber.New()
50-
51-
two.Use("/three", three)
52-
one.Use("/two", two)
53-
app.Use("/one", one)
46+
app := fiber.New()
47+
one := fiber.New()
48+
two := fiber.New()
49+
three := fiber.New()
50+
51+
two.Use("/three", three)
52+
one.Use("/two", two)
53+
app.Use("/one", one)
5454

55-
one.MountPath() // "/one"
56-
two.MountPath() // "/one/two"
57-
three.MountPath() // "/one/two/three"
58-
app.MountPath() // ""
55+
one.MountPath() // "/one"
56+
two.MountPath() // "/one/two"
57+
three.MountPath() // "/one/two/three"
58+
app.MountPath() // ""
5959
}
6060
```
6161

@@ -91,7 +91,7 @@ func main() {
9191

9292
### Route
9393

94-
Returns an instance of a single route, which you can then use to handle HTTP verbs with optional middleware.
94+
Returns an instance of a single route, which you can then use to handle HTTP verbs with optional middleware.
9595

9696
Similar to [`Express`](https://expressjs.com/de/api.html#app.route).
9797

@@ -120,6 +120,7 @@ type Register interface {
120120
Route(path string) Register
121121
}
122122
```
123+
123124
</details>
124125

125126
```go title="Examples"
@@ -222,6 +223,7 @@ func main() {
222223
]
223224
]
224225
```
226+
225227
</details>
226228

227229
### Name
@@ -328,6 +330,7 @@ func main() {
328330
null
329331
]
330332
```
333+
331334
</details>
332335

333336
### GetRoute
@@ -347,10 +350,10 @@ func main() {
347350
app.Get("/", handler).Name("index")
348351

349352
data, _ := json.MarshalIndent(app.GetRoute("index"), "", " ")
350-
fmt.Print(string(data))
353+
fmt.Print(string(data))
351354

352355

353-
app.Listen(":3000")
356+
app.Listen(":3000")
354357
}
355358
```
356359

@@ -365,6 +368,7 @@ func main() {
365368
"params": null
366369
}
367370
```
371+
368372
</details>
369373

370374
### GetRoutes
@@ -376,14 +380,15 @@ func (app *App) GetRoutes(filterUseOption ...bool) []Route
376380
```
377381

378382
When filterUseOption equal to true, it will filter the routes registered by the middleware.
383+
379384
```go title="Examples"
380385
func main() {
381-
app := fiber.New()
382-
app.Post("/", func (c fiber.Ctx) error {
383-
return c.SendString("Hello, World!")
384-
}).Name("index")
385-
data, _ := json.MarshalIndent(app.GetRoutes(true), "", " ")
386-
fmt.Print(string(data))
386+
app := fiber.New()
387+
app.Post("/", func (c fiber.Ctx) error {
388+
return c.SendString("Hello, World!")
389+
}).Name("index")
390+
data, _ := json.MarshalIndent(app.GetRoutes(true), "", " ")
391+
fmt.Print(string(data))
387392
}
388393
```
389394

@@ -400,6 +405,7 @@ func main() {
400405
}
401406
]
402407
```
408+
403409
</details>
404410

405411
## Config
@@ -436,12 +442,12 @@ func (app *App) NewCtxFunc(function func(app *App) CustomCtx)
436442

437443
```go title="Examples"
438444
type CustomCtx struct {
439-
DefaultCtx
445+
DefaultCtx
440446
}
441447

442448
// Custom method
443449
func (c *CustomCtx) Params(key string, defaultValue ...string) string {
444-
return "prefix_" + c.DefaultCtx.Params(key)
450+
return "prefix_" + c.DefaultCtx.Params(key)
445451
}
446452

447453
app := New()
@@ -521,7 +527,6 @@ func (app *App) RegisterCustomConstraint(constraint CustomConstraint)
521527

522528
See [Custom Constraint](../guide/routing.md#custom-constraint) section for more information.
523529

524-
525530
## SetTLSHandler
526531

527532
Use SetTLSHandler to set [ClientHelloInfo](https://datatracker.ietf.org/doc/html/rfc8446#section-4.1.2) when using TLS with Listener.

docs/core/api/bind.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ Make copies or use the [**`Immutable`**](./ctx.md) setting instead. [Read more..
1515

1616
:::
1717

18-
1918
## Binders
2019

2120
- [Body](#body)
22-
- [Form](#form)
23-
- [JSON](#json)
24-
- [MultipartForm](#multipartform)
25-
- [XML](#xml)
21+
- [Form](#form)
22+
- [JSON](#json)
23+
- [MultipartForm](#multipartform)
24+
- [XML](#xml)
2625
- [Cookie](#cookie)
2726
- [Header](#header)
2827
- [Query](#query)
@@ -80,7 +79,6 @@ app.Post("/", func(c fiber.Ctx) error {
8079
// curl -X POST "http://localhost:3000/?name=john&pass=doe"
8180
```
8281

83-
8482
**The methods for the various bodies can also be used directly:**
8583

8684
#### Form
@@ -89,7 +87,6 @@ Binds the request form body to a struct.
8987

9088
It is important to specify the correct struct tag based on the content type to be parsed. For example, if you want to parse a Form body with a field called Pass, you would use a struct field of `form:"pass"`.
9189

92-
9390
```go title="Signature"
9491
func (b *Bind) Form(out any) error
9592
```
@@ -125,7 +122,6 @@ Binds the request json body to a struct.
125122

126123
It is important to specify the correct struct tag based on the content type to be parsed. For example, if you want to parse a JSON body with a field called Pass, you would use a struct field of `json:"pass"`.
127124

128-
129125
```go title="Signature"
130126
func (b *Bind) JSON(out any) error
131127
```
@@ -162,7 +158,6 @@ Binds the request multipart form body to a struct.
162158

163159
It is important to specify the correct struct tag based on the content type to be parsed. For example, if you want to parse a MultipartForm body with a field called Pass, you would use a struct field of `form:"pass"`.
164160

165-
166161
```go title="Signature"
167162
func (b *Bind) MultipartForm(out any) error
168163
```
@@ -197,8 +192,7 @@ app.Post("/", func(c fiber.Ctx) error {
197192

198193
Binds the request xml form body to a struct.
199194

200-
It is important to specify the correct struct tag based on the content type to be parsed. For example, if you want to parse a XML body with a field called Pass, you would use a struct field of `xml:"pass"`.
201-
195+
It is important to specify the correct struct tag based on the content type to be parsed. For example, if you want to parse an XML body with a field called Pass, you would use a struct field of `xml:"pass"`.
202196

203197
```go title="Signature"
204198
func (b *Bind) XML(out any) error
@@ -229,7 +223,6 @@ app.Post("/", func(c fiber.Ctx) error {
229223
// curl -X POST -H "Content-Type: application/xml" --data "<login><name>john</name><pass>doe</pass></login>" localhost:3000
230224
```
231225

232-
233226
### Cookie
234227

235228
This method is similar to [Body-Binding](#body), but for cookie parameters.
@@ -262,7 +255,6 @@ app.Get("/", func(c fiber.Ctx) error {
262255
// curl.exe --cookie "name=Joseph; age=23; job=true" http://localhost:8000/
263256
```
264257

265-
266258
### Header
267259

268260
This method is similar to [Body-Binding](#body), but for request headers.
@@ -298,7 +290,6 @@ app.Get("/", func(c fiber.Ctx) error {
298290
// curl "http://localhost:3000/" -H "name: john" -H "pass: doe" -H "products: shoe,hat"
299291
```
300292

301-
302293
### Query
303294

304295
This method is similar to [Body-Binding](#body), but for query parameters.
@@ -342,7 +333,6 @@ app.Get("/", func(c fiber.Ctx) error {
342333
For more parser settings please look here [Config](fiber.md#enablesplittingonparsers)
343334
:::
344335

345-
346336
### RespHeader
347337

348338
This method is similar to [Body-Binding](#body), but for response headers.
@@ -467,7 +457,6 @@ It's default behavior of binder.
467457
func (b *Bind) Should() *Bind
468458
```
469459

470-
471460
## SetParserDecoder
472461

473462
Allow you to config BodyParser/QueryParser decoder, base on schema's options, providing possibility to add custom type for parsing.
@@ -542,7 +531,6 @@ app.Get("/query", func(c fiber.Ctx) error {
542531

543532
```
544533

545-
546534
## Validation
547535

548536
Validation is also possible with the binding methods. You can specify your validation rules using the `validate` struct tag.
@@ -585,6 +573,3 @@ app.Post("/", func(c fiber.Ctx) error {
585573
}
586574
})
587575
```
588-
589-
590-

0 commit comments

Comments
 (0)