Validating requests is costly - roughly 40% of dispatching time is spent on schema validation. If you know the incoming requests are valid, you can disable the validation for better performance.
dispatch(request, validator=lambda _: None)
I suggest:
200 if response else 204
If the request was a notification, dispatch will give you an empty string. So
since there’s no http body, use status code 204 - no content.
Use @method(name="new_name").
Or use the dispatch function’s methods parameter.
Instead of dispatch, use:
dispatch_to_serializable to get the response as a dict.dispatch_to_response to get the response as a namedtuple (either a
SuccessResponse or ErrorResponse, these are defined in
response.py).For these functions, if the request was a batch, you’ll get a list of
responses. If the request was a notification, you’ll get None.