Commit graph

17 commits

Author SHA1 Message Date
google-labs-jules[bot]
82099e26ee feat: Add request body size limit and enhance error logging
This commit introduces two main improvements to the Touka web framework:

1.  **Configurable Request Body Size Limit:**
    - Added `MaxRequestBodySize int64` to `touka.Engine` (default 10MB).
    - You can customize this via `engine.SetMaxRequestBodySize()`.
    - The context methods `GetReqBodyFull()`, `GetReqBodyBuffer()`, and `ShouldBindJSON()` now adhere to this limit. They check `Content-Length` upfront and use `http.MaxBytesReader` to prevent reading excessively large request bodies into memory, enhancing protection against potential DoS attacks or high memory usage.
    - Added comprehensive unit tests in `context_test.go` for this feature, covering scenarios where the limit is active, disabled, and exceeded.

2.  **Enhanced Error Logging in Default Handler:**
    - The `defaultErrorHandle` in `engine.go` now logs not only the primary error passed to it but also any additional errors collected in `Context.Errors` (via `c.AddError()`).
    - This provides more comprehensive diagnostic information in the logs without altering the JSON error response structure sent to the client, ensuring backward compatibility.

These changes aim to improve the framework's robustness, memory safety, and debuggability.
2025-06-20 06:35:01 +00:00
wjqserver
53544644af use new resolveRoutePath replace path.Join && add UseIf 2025-06-17 14:20:14 +08:00
wjqserver
ebb634b643 update default error handle 2025-06-13 17:53:48 +08:00
wjqserver
0076c7538c fix default error handle 2025-06-13 14:41:10 +08:00
wjqserver
803a6747f6 update serve && add custom srv configure 2025-06-12 09:40:46 +08:00
wjqserver
9a2aeef0d0 remove ANY form MethodsSet to avoid conflict 2025-06-11 11:23:15 +08:00
wjqserver
bb822599b9 update methods 2025-06-11 11:11:54 +08:00
wjqserver
ce5efae287 update 2025-06-10 21:37:53 +08:00
wjqserver
450d6294ad remove dup engine.pool.Put(c) 2025-06-06 22:13:17 +08:00
wjqserver
81fd3902cb fix ctx lifetime 2025-06-06 21:43:16 +08:00
wjqserver
69469c0306 fix NoRoutes 2025-06-05 20:47:41 +08:00
wjqserver
c6c65c04a7 [engine] add NoRoutes 2025-06-05 20:31:18 +08:00
wjqserver
31d2065f07 [engine] add StaticFile 2025-06-04 21:50:03 +08:00
wjqserver
899d3ff48b add logreco 2025-06-04 20:44:23 +08:00
wjqserver
52b900db92 fix fileserver status chain 2025-05-30 21:31:54 +08:00
wjqserver
54ff216eff add static 2025-05-29 21:27:35 +08:00
wjqserver
484f2f016b init(v0.0.1) 2025-05-28 18:25:28 +08:00