You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Drop method to Fiber context API documentation
The `Drop` method allows silently terminating client connections without sending HTTP headers or a response body. This is useful for scenarios like mitigating DDoS attacks or blocking unauthorized access to sensitive endpoints. Example usage and function signature are included in the updated documentation.
Terminates the client connection silently without sending any HTTP headers or response body.
469
+
470
+
This can be used for scenarios where you want to block certain requests without notifying the client, such as mitigating
471
+
DDoS attacks or protecting sensitive endpoints from unauthorized access.
472
+
473
+
```go title="Signature"
474
+
func(cfiber.Ctx) Drop() error
475
+
```
476
+
477
+
```go title="Example"
478
+
app.Get("/", func(c fiber.Ctx) error {
479
+
if c.IP() == "192.168.1.1" {
480
+
return c.Drop()
481
+
}
482
+
483
+
return c.SendString("Hello, " + name)
484
+
})
485
+
```
486
+
487
+
466
488
## Format
467
489
468
490
Performs content-negotiation on the [Accept](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept) HTTP header. It uses [Accepts](ctx.md#accepts) to select a proper format from the supplied offers. A default handler can be provided by setting the `MediaType` to `"default"`. If no offers match and no default is provided, a 406 (Not Acceptable) response is sent. The Content-Type is automatically set when a handler is selected.
0 commit comments