{"repo":"florimondmanca/msgpack-asgi","free":true,"listed":false,"github":"https://github.com/florimondmanca/msgpack-asgi","clone":"git clone https://github.com/florimondmanca/msgpack-asgi.git","description":"Drop-in MessagePack support for ASGI applications and frameworks","language":"Python","stars":277,"topics":["python","asgi","middleware","messagepack","msgpack","json","starlette","fastapi"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"msgpack-asgi msgpack-asgi allows you to add automatic MessagePack content negotiation to ASGI applications (Starlette, FastAPI, Quart, etc.), with a single line of code: (Adapt this snippet to your framework-specific middleware API.) This gives you the bandwitdth usage reduction benefits of MessagePack without having to change existing code. Note : this comes at a CPU usage cost, since MessagePackMiddleware will perform MsgPack decoding while your application continues to decode and encode JSON data (see also How it works). If your use case is CPU-sensitive, rather than strictly focused on reducing network bandwidth, this package may not be for you. Installation Install with pip: Be sure to pin to the latest major version , as above. Breaking changes may occur across major versions. If so, details on migration steps will be provided in CHANGELOG.md. Quickstart First, you'll need an ASGI application. Let's use this sample application, which exposes an endpoint that returns JSON data: Then, wrap your application around MessagePackMiddleware : Serve your application using an ASGI server, for example with Uvicorn: Now, let's make a request that accepts MessagePack data in response: You should get the following output: What happened? Since we told the application that we accepted MessagePack-encoded responses, msgpack-asgi automatically converted the JSON data returned by the Starlette application to MessagePack. We can make sure the response contains valid MessagePack data by mak","default_branch":null,"files":null,"tree":[],"storefront":"/r/florimondmanca","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/florimondmanca/msgpack-asgi/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}