24 lines
665 B
Python
24 lines
665 B
Python
from litestar.types import Scope, Receive, Send, ASGIApp
|
|
from litestar.middleware import ASGIMiddleware
|
|
from litestar.enums import ScopeType
|
|
from litestar.datastructures import Headers
|
|
from pprint import pprint
|
|
|
|
class UrlEncodedMiddleware(ASGIMiddleware):
|
|
scopes = (ScopeType.HTTP,)
|
|
|
|
async def handle(
|
|
self,
|
|
scope: Scope,
|
|
receive: Receive,
|
|
send: Send,
|
|
next_app: ASGIApp
|
|
) -> None:
|
|
headers = Headers.from_scope(scope)
|
|
if scope['method'] in ['POST', 'PUT', 'PATCH'] and headers['Content-Type'] == 'application/x-www-form-urlencoded':
|
|
pass
|
|
|
|
|
|
await next_app(scope, receive, send)
|
|
|