django_aws_api_gateway_websockets package#
Submodules#
django_aws_api_gateway_websockets.apps module#
django_aws_api_gateway_websockets.urls module#
django_aws_api_gateway_websockets.views module#
- class WebSocketView(**kwargs)[source]#
Bases:
View
The base WebSocket View for handling messages sent from the client via AWS API Gateway
- aws_api_gateway_id = None#
- body = {}#
- connect(request, *args, **kwargs) Union[JsonResponse, HttpResponseBadRequest] [source]#
Handle the connection route in a standard way that ensures the User to Connectionid mapping persists
- default(request, *args, **kwargs) JsonResponse [source]#
OVerload this method if you want to have a default message handler
- disconnect(request, *args, **kwargs) JsonResponse [source]#
Using connectionId update websocket table to show as disconnected
- dispatch(request, *args, **kwargs)[source]#
Determine the correct method to call. The method will map to the route_selection_key or default.
Checks for the expected headers. Tries to dispatch to the right method; if a method doesn’t exist defer to the default handler. If the Route Selection Key is missing defer to the route selection error handler. If the request method isn’t on the approved list then defer to the normal error handler .
- expected_useragent_prefix = 'AmazonAPIGateway_'#
- invalid_useragent(request, *args, **kwargs) HttpResponseBadRequest [source]#
Method for handling unexpected useragents
- missing_headers(request, *args, **kwargs) HttpResponseBadRequest [source]#
Method for handling missing headers
- model = None#
- required_connection_headers = ['Cookie', 'Origin', 'Sec-Websocket-Extensions', 'Sec-Websocket-Key', 'Sec-Websocket-Version']#
- required_headers = ['Host', 'X-Real-Ip', 'X-Forwarded-For', 'X-Forwarded-Proto', 'Connection', 'Content-Length', 'X-Forwarded-Port', 'X-Amzn-Trace-Id', 'Connectionid', 'User-Agent', 'X-Amzn-Apigateway-Api-Id']#
- route_selection_key = 'action'#