2

Im looking to make my Flask based API case insensitive for all incoming payloads. rather than having to apply this to all api-route functions i want to apply this to the @app.before_request decorator, such that for all incoming requests with json payloads (POSTs and PUTs) I directly edit the payload before it is handled by the applicable app.route function.

POST {"x":1, "Y":2} Should be formatted to POST {"x":1, "y":2} for request endpoints, but I can't seem to make this happen.

@app.before_request
def before_request():
    if request.json:
        data = RecusivelyLowerKeys(request.get_json())
        request.data = json.dumps(ldata)

so far this approach hasn't worked and the original request payload seems static.

Any tips or alternative approaches would be appreciated thanks.

callum91
  • 41
  • 7
  • 1
    As someone would built and consumed many REST APIs I advise to keep the API case sensitive and use is properly instead. Just like your `RecusivelyLowerKeys` which is used like a function and is confusingly capitalized like a class. – Klaus D. Jun 16 '17 at 11:05
  • I'm well aware that this is not standard. My API is not intended for public use and case insensitivity has been requested by a client. – callum91 Jun 19 '17 at 09:16

0 Answers0