-
Notifications
You must be signed in to change notification settings - Fork 6
Class: Controller
The Controller Class is the main entry/exit point of the AWS LAMBDA CMS back-end. Controller.py is the lambda function endpoint for the API Gateway of the CMS, and functions just like a traditional web server endpoint, such that it receives the requests from the API Gateway, processes the input data, and returns an appropriate response as required.
| Name | Description |
|---|---|
| handler | The main function called by LAMBDA. |
| process_request | Processes and calls required classes/functions based on request type. |
| supported_request | Validates that the supplied request is supported by the CMS. |
| remove_prefix | Strips the Cookie header prefix from the supplied Cookie. |
| strip_dynamo_types | Strips the DynamoDB datatype prefixes from a given set of data. |
The main function called by LAMBDA where all back-end functionality is performed for the CMS.
Parameters
event - The LAMBDA event parameter (required by AWS)
context - The LAMBDA context parameter (required by AWS)
Returns
Response - Response JSON data (specific to request type)
Throws
noRequest - No request has been specified.
unsupportedRequest - The request supplied is not supported by the CMS.
noToken - The user performing the request does not have a valid token.
Botocore Exception - Refer to Botocore documentation
Takes a valid process request, and performs subroutine calls based on the request type.
Parameters
request_body - The request body data supplied to the API Gateway (POST body).
Returns
Response - Response JSON data (specific to request type)
Throws
unsupportedRequest - The request supplied is not supported by the CMS.
Validates that the supplied request is infact supported by the CMS.
Parameters
request - The request type to validate.
Returns
isSupported - Returns true/false depending on if the request type is supported.
Removes the Cookie header prefix from the received Cookie.
Parameters
Cookie - The Cookie header to strip.
Returns
Cookie Value - Returns the Cookie value which has had the header prefix removed.
Removes the DynamoDB data type prefixes from DynamoDB datasets.
Parameters
Response - The DynamoDB dataset.
Returns
Response - The provided DynamoDB dataset, with datatypes stripped from the data contents.