Skip to content

Commit c09ab73

Browse files
Add docs from gofiber/fiber@aa245ae
1 parent c8a47b1 commit c09ab73

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

docs/core/whats_new.md

+32-1
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ testConfig := fiber.TestConfig{
341341
- **String**: Similar to Express.js, converts a value to a string.
342342
- **ViewBind**: Binds data to a view, replacing the old `Bind` method.
343343
- **CBOR**: Introducing [CBOR](https://cbor.io/) binary encoding format for both request & response body. CBOR is a binary data serialization format which is both compact and efficient, making it ideal for use in web applications.
344-
- **End**: Similar to Express.js, immediately flushes the current response and closes the underlying connection.
345344
- **Drop**: Terminates the client connection silently without sending any HTTP headers or response body. This can be used for scenarios where you want to block certain requests without notifying the client, such as mitigating DDoS attacks or protecting sensitive endpoints from unauthorized access.
345+
- **End**: Similar to Express.js, immediately flushes the current response and closes the underlying connection.
346346

347347
### Removed Methods
348348

@@ -405,6 +405,37 @@ app.Get("/sse", func(c fiber.Ctx) {
405405

406406
You can find more details about this feature in [/docs/api/ctx.md](./api/ctx.md).
407407

408+
### Drop
409+
410+
In v3, we introduced support to silently terminate requests through `Drop`.
411+
412+
```go
413+
func (c Ctx) Drop()
414+
```
415+
416+
With this method, you can:
417+
418+
- Block certain requests without notifying the client to mitigate DDoS attacks
419+
- Protect sensitive endpoints from unauthorized access without leaking errors.
420+
421+
:::caution
422+
While this feature adds the ability to drop connections, it is still **highly recommended** to use additional
423+
measures (such as **firewalls**, **proxies**, etc.) to further protect your server endpoints by blocking
424+
malicious connections before the server establishes a connection.
425+
:::
426+
427+
```go
428+
app.Get("/", func(c fiber.Ctx) error {
429+
if c.IP() == "192.168.1.1" {
430+
return c.Drop()
431+
}
432+
433+
return c.SendString("Hello World!")
434+
})
435+
```
436+
437+
You can find more details about this feature in [/docs/api/ctx.md](./api/ctx.md).
438+
408439
### End
409440

410441
In v3, we introduced a new method to match the Express.js API's `res.end()` method.

0 commit comments

Comments
 (0)