Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://nf1s.github.io/sanic-camelcase-middleware/
Middleware for camelizing request and response bodies for sanic
https://nf1s.github.io/sanic-camelcase-middleware/
middleware mkdocs python python3 python36 sanic sanic-framework sanic-middleware
Last synced: 3 months ago
JSON representation
Middleware for camelizing request and response bodies for sanic
- Host: GitHub
- URL: https://nf1s.github.io/sanic-camelcase-middleware/
- Owner: nf1s
- License: mit
- Created: 2020-02-09T18:04:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T12:40:29.000Z (almost 2 years ago)
- Last Synced: 2024-07-08T21:43:18.423Z (4 months ago)
- Topics: middleware, mkdocs, python, python3, python36, sanic, sanic-framework, sanic-middleware
- Language: Python
- Homepage: https://ahmednafies.github.io/sanic_camelcase_middleware/
- Size: 834 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-sanic - Sanic-CamelCase-Middleware
README
# Sanic Camelcase Middleware
[![CircleCI](https://circleci.com/gh/nf1s/sanic-camelcase-middleware.svg?style=shield)](https://circleci.com/gh/nf1s/sanic-camelcase-middleware) [![codecov](https://codecov.io/gh/nf1s/sanic-camelcase-middleware/branch/master/graph/badge.svg)](https://codecov.io/gh/nf1s/sanic-camelcase-middleware) [![Downloads](https://pepy.tech/badge/sanic-camelcase-middleware)](https://pepy.tech/project/sanic-camelcase-middleware) ![GitHub Pipenv locked Python version](https://img.shields.io/github/pipenv/locked/python-version/nf1s/sanic-camelcase-middleware) ![GitHub](https://img.shields.io/github/license/nf1s/sanic-camelcase-middleware)
Middleware for camelizing request and response bodies for sanic
Full documentation can be found [here](https://nf1s.github.io/sanic-camelcase-middleware/)
## How to install
```bash
pip install sanic-camelcase-middlware
```### Example
```python
from sanic import Sanic
from sanic_camelcase_middleware import Camelizeapp = Sanic(__name__)
Camelize(app)
```### Full example
```python
from sanic import Sanic
from sanic.response import json
from sanic_camelcase_middleware import Camelizeapp = 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
```python
from sanic import Sanic
from sanic_camelcase_middleware import Camelizeapp = Sanic(__name__)
# default `decamelize_request=True`
Camelize(app, decamelize_request=False)```
### To disable the middleware for response body
```python
from sanic import Sanic
from sanic_camelcase_middleware import Camelizeapp = Sanic(__name__)
# default `camelize_response=True`
Camelize(app, camelize_response=False)```