django_aws_api_gateway_websockets package#

Submodules#

django_aws_api_gateway_websockets.apps module#

class DjangoAwsApiGatewayWebsocketsConfig(app_name, app_module)[source]#

Bases: AppConfig

default_auto_field = 'django.db.models.BigAutoField'#
name = 'django_aws_api_gateway_websockets'#
verbose_name = 'Django AWS ApiGateway Websockets'#

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'#
route_selection_key_missing(request, *args, **kwargs) HttpResponseBadRequest[source]#

Method for handling missing route_selection_key

setup(request, *args, **kwargs)[source]#

Converts the request.body string back into a dictionary and assign to the objets body property for ease

Module contents#