-
-
Notifications
You must be signed in to change notification settings - Fork 7
Update body limit configuration to support size units #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,9 +26,11 @@ type ( | |
| // If value is 0, rate limit is set default value. | ||
| RequestLimitTimeWindow uint64 | ||
|
|
||
| // BodyLimit is a maximum size of request body. | ||
| // If value is 0, body limit is disabled. | ||
| BodyLimit uint64 | ||
| // BodyLimit sets the maximum allowed size for the request body. | ||
| // If set to the empty string (`""`), no body size limit is enforced. | ||
| // Accepted formats are an integer followed by an optional unit, e.g. `4K`, `4KB`, `10M`, `1G`. | ||
| // Supported units: K, M, G, T, P (optionally followed by `B`), case-insensitive. | ||
| BodyLimit string | ||
| } | ||
|
|
||
| // Server is HTTP server that wraps Ferret worker. | ||
|
|
@@ -76,8 +78,8 @@ func New(logger *lecho.Logger, opts Options) (*Server, error) { | |
| AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept}, | ||
| })) | ||
|
|
||
| if opts.BodyLimit > 0 { | ||
| router.Use(middleware.BodyLimit(fmt.Sprintf("%d", opts.BodyLimit))) | ||
| if opts.BodyLimit != "" { | ||
| router.Use(middleware.BodyLimit(opts.BodyLimit)) | ||
|
Comment on lines
+81
to
+82
|
||
| } | ||
|
|
||
| router.Use(middleware.RequestID()) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.