Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Feb 21, 2024
1 parent dcdba98 commit a5e6ed8
Show file tree
Hide file tree
Showing 43 changed files with 796 additions and 581 deletions.
26 changes: 18 additions & 8 deletions versioned_docs/version-v2.x/api/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func main() {
micro := fiber.New()
app.Mount("/john", micro) // GET /john/doe -> 200 OK
micro.Get("/doe", func(c *fiber.Ctx) error {
micro.Get("/doe", func(c fiber.Ctx) error {
return c.SendStatus(fiber.StatusOK)
})
Expand Down Expand Up @@ -205,7 +205,7 @@ func main() {
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)
api.Get("/bar", handler).Name("bar") // /test/bar (name: test.bar)
}, "test.")
log.Fatal(app.Listen(":3000"))
Expand Down Expand Up @@ -261,7 +261,7 @@ func (app *App) Stack() [][]*Route
```
```go title="Examples"
var handler = func(c *fiber.Ctx) error { return nil }
var handler = func(c fiber.Ctx) error { return nil }
func main() {
app := fiber.New()
Expand Down Expand Up @@ -315,7 +315,7 @@ func (app *App) Name(name string) Router
```
```go title="Examples"
var handler = func(c *fiber.Ctx) error { return nil }
var handler = func(c fiber.Ctx) error { return nil }
func main() {
app := fiber.New()
Expand Down Expand Up @@ -417,7 +417,7 @@ func (app *App) GetRoute(name string) Route
```
```go title="Examples"
var handler = func(c *fiber.Ctx) error { return nil }
var handler = func(c fiber.Ctx) error { return nil }
func main() {
app := fiber.New()
Expand Down Expand Up @@ -454,7 +454,7 @@ When filterUseOption equal to true, it will filter the routes registered by the
```go title="Examples"
func main() {
app := fiber.New()
app.Post("/", func (c *fiber.Ctx) error {
app.Post("/", func (c fiber.Ctx) error {
return c.SendString("Hello, World!")
}).Name("index")
data, _ := json.MarshalIndent(app.GetRoutes(true), "", " ")
Expand Down Expand Up @@ -617,6 +617,16 @@ ln = tls.NewListener(ln, &tls.Config{Certificates: []tls.Certificate{cer}})
app.Listener(ln)
```
## RegisterCustomConstraint
RegisterCustomConstraint allows to register custom constraint.
```go title="Signature"
func (app *App) RegisterCustomConstraint(constraint CustomConstraint)
```
See [Custom Constraint](../guide/routing.md#custom-constraint) section for more information.
## Test
Testing your application is done with the **Test** method. Use this method for creating `_test.go` files or when you need to debug your routing logic. The default timeout is `1s` if you want to disable a timeout altogether, pass `-1` as a second argument.
Expand All @@ -627,7 +637,7 @@ func (app *App) Test(req *http.Request, msTimeout ...int) (*http.Response, error
```go title="Examples"
// Create route with GET method for test:
app.Get("/", func(c *fiber.Ctx) error {
app.Get("/", func(c fiber.Ctx) error {
fmt.Println(c.BaseURL()) // => http://google.com
fmt.Println(c.Get("X-Custom-Header")) // => hi
Expand All @@ -654,4 +664,4 @@ Hooks is a method to return [hooks](../guide/hooks.md) property.

```go title="Signature"
func (app *App) Hooks() *Hooks
```
```
10 changes: 5 additions & 5 deletions versioned_docs/version-v2.x/api/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (c *Client) Delete(url string) *Agent
Here we present a brief example demonstrating the simulation of a proxy using our `*fiber.Agent` methods.
```go
// Get something
func getSomething(c *fiber.Ctx) (err error) {
func getSomething(c fiber.Ctx) (err error) {
agent := fiber.Get("<URL>")
statusCode, body, errs := agent.Bytes()
if len(errs) > 0 {
Expand All @@ -43,7 +43,7 @@ func getSomething(c *fiber.Ctx) (err error) {
}

// Post something
func createSomething(c *fiber.Ctx) (err error) {
func createSomething(c fiber.Ctx) (err error) {
agent := fiber.Post("<URL>")
agent.Body(c.Body()) // set body received by request
statusCode, body, errs := agent.Bytes()
Expand Down Expand Up @@ -271,7 +271,7 @@ agent.BodyStream(strings.NewReader("body=stream"), -1)
JSON sends a JSON request by setting the Content-Type header to the `ctype` parameter. If no `ctype` is passed in, the header is set to `application/json`.

```go title="Signature"
func (a *Agent) JSON(v interface{}, ctype ...string) *Agent
func (a *Agent) JSON(v any, ctype ...string) *Agent
```

```go title="Example"
Expand All @@ -284,7 +284,7 @@ agent.JSON(fiber.Map{"success": true})
XML sends an XML request by setting the Content-Type header to `application/xml`.

```go title="Signature"
func (a *Agent) XML(v interface{}) *Agent
func (a *Agent) XML(v any) *Agent
```

```go title="Example"
Expand Down Expand Up @@ -636,7 +636,7 @@ code, body, errs := agent.String()
Struct returns the status code, bytes body and errors of url. And bytes body will be unmarshalled to given v.
```go title="Signature"
func (a *Agent) Struct(v interface{}) (code int, body []byte, errs []error)
func (a *Agent) Struct(v any) (code int, body []byte, errs []error)
```
```go title="Example"
Expand Down
Loading

0 comments on commit a5e6ed8

Please sign in to comment.