Repository navigation
Add body size limits and server configurations - #3
Merged
Merged
Conversation
- Update Default and New to return *Application type. - Add Address and SetAddress methods to Application. - Add Application method to Request and Response. Signed-off-by: Chen Su <ghosind@gmail.com>
Signed-off-by: Chen Su <ghosind@gmail.com>
Signed-off-by: Chen Su <ghosind@gmail.com>
Signed-off-by: Chen Su <ghosind@gmail.com>
- Update max response body size config to atomic.Int64. - Add configurable shutdown signal listening. - Setter methods return *Application to support chaining. Signed-off-by: Chen Su <ghosind@gmail.com>
Signed-off-by: Chen Su <ghosind@gmail.com>
Signed-off-by: Chen Su <ghosind@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR hardens the HTTP server defaults and adds configurable request/response body size limits, while also adjusting the public construction API to return *Application for direct configuration.
Changes:
- Introduces request body limiting (
http.MaxBytesReader) and response buffering with max-size enforcement. - Adds server configuration defaults (timeouts, max header bytes) and exposes option/setter APIs to configure them.
- Updates documentation and tests to reflect new configuration surface area and breaking API return types.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| response.go | Buffers responses and enforces a configurable maximum response body size. |
| response_test.go | Adds/updates unit tests for response body limits and Application association. |
| request.go | Adds request body limiting, query caching/copying, and Application association on requests. |
| request_test.go | Adds/updates unit tests for request body limits, idempotent Body(), and ClientIP formatting. |
| README.md | Documents new configuration options and updates handler signature example. |
| option.go | Expands Option helpers to configure server timeouts, header limits, body limits, and shutdown behavior via setters. |
| option_test.go | Adds test coverage for the expanded option surface. |
| errors.go | Adds ErrResponseTooLarge for response body limit enforcement. |
| app.go | Adds server defaults, body-limit settings, shutdown configuration, and updates constructors to return *Application. |
| app_unix_test.go | Updates tests for constructor return type change. |
| app_test.go | Updates/extends tests for new configuration getters/setters and constructor return type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+175
to
+178
| // TODO: add error handling | ||
| _ = ctx.Next() | ||
|
|
||
| _ = resp.send() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds request/response body size limits, HTTP server configurations (timeouts, max header size, etc.), and thread-safety improvements.
Key Changes
Breaking Changes
*Applicationinstead of theApplicationinterface.