hug
hug copied to clipboard
Converting request body from camelCase to snake_case
I've been having quite a bit of trouble to do this.
The main issue is that Falcon's request.bounded_stream can only be read once, so the API's JSON decoder ends up reading nothing after this is read in hug's request_middleware. I've tried creating another stream from the initial stream after it's been read, and then assigning that to request.bounded_stream, but no luck...
@hug.request_middleware()
def process_request(request, response):
data = request.bounded_stream.read()
stream = io.BytesIO(data)
request.bounded_stream = stream
Is there any way around this issue?