effectiveBodyLimit function
The smaller of limit and whatever the router configured.
Two places set a body limit and neither may loosen the other:
Router(bodyLimit:) bounds the whole application, an extractor bounds one
route. Taking the minimum means adding either can only ever refuse more — in
particular, a route that asks for 1 KB is not widened by a looser
application-wide limit.
Implementation
int effectiveBodyLimit(Request request, int limit) {
final configured = request.context[bodyLimitContextKey];
return configured is int && configured < limit ? configured : limit;
}