Skip to main content

Middleware for camelizing request and response bodies for Sanic

Project description

Sanic Camelcase Middleware

CircleCI codecov Downloads GitHub Pipenv locked Python version GitHub

Middleware for camelizing request and response bodies for sanic

Full documentation can be found here

How to install

    pip install sanic-camelcase-middlware

Example

    from sanic import Sanic
    from sanic_camelcase_middleware import Camelize

    app = Sanic(__name__)
    Camelize(app)

Full example

    from sanic import Sanic
    from sanic.response import json
    from sanic_camelcase_middleware import Camelize

    app = Sanic(__name__)

    Camelize(app)


    @app.route("/post", methods=["POST"])
    async def test(request):
        return json("is_camelcase": True, "message": request.json})


    if __name__ == "__main__":
        app.run(host="0.0.0.0", port=8000)

To disable the middleware for request payload

    from sanic import Sanic
    from sanic_camelcase_middleware import Camelize

    app = Sanic(__name__)

    # default `decamelize_request=True`
    Camelize(app, decamelize_request=False)

To disable the middleware for response body

    from sanic import Sanic
    from sanic_camelcase_middleware import Camelize

    app = Sanic(__name__)

    # default `camelize_response=True`
    Camelize(app, camelize_response=False)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sanic_camelcase_middleware-1.3.0.tar.gz (2.7 kB view details)

Uploaded Source

File details

Details for the file sanic_camelcase_middleware-1.3.0.tar.gz.

File metadata

  • Download URL: sanic_camelcase_middleware-1.3.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5

File hashes

Hashes for sanic_camelcase_middleware-1.3.0.tar.gz
Algorithm Hash digest
SHA256 902acd247062c44ce82c0bf7082e633181ad85d500139624e3ded8313ba7a205
MD5 b15596baff4b51233f2ba5af93bc5fb8
BLAKE2b-256 39cfba9296554ef172392256903b66b45191266ba554285dcece9eaed0328a13

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page