-
-
Notifications
You must be signed in to change notification settings - Fork 170
Description
We have a middleware for limiting your apps body request size https://github.com/luckyframework/lucky/blame/main/src/lucky/maximum_request_size_handler.cr
But this handler is expected to work on the whole app. If you set your app's limit to say 100mb because 1 API endpoint allows for it, then all the rest of them are still allowing 100mb. We should have a way to tune this at a per action base level.
For example, globally I want my app set to 1MB, but for 1 or 2 actions, I want to allow 25MB. Or maybe one allows 25MB and another allow 100MB.
The tricky part is this handler would sit before your route handler in the stack. So it wouldn't know which Action is going to be used until after it's already blocked the request. We probably just need a second module that works as an action pipe.
class Resumes::Create < ApiAction
include Lucky::EnsureMaxBodySize
# Some sort of method that tells how big in kb?
set_body_size_limit 25000
end
module Lucky::EnsureMaxBodySize
# adds that method in and includes
# a before pipe to check it... maybe also checks Content-Length header?
end