Origin Request handler

Operations

  • If a client sends a GET request for a URI that ends with a slash (i.e. /foo/) then the handler will transform the request to include the directory’s index file (i.e. /foo/index.html).

  • If a client sends a GET request for a URI that does not end with a slash and the final item in the path does not contain a period (i.e. /foo/bar) then a redirect is returned to the client to try again with a slash (i.e. /foo/bar/)

  • …otherwise, the request is passed unmodified to the origin.

Basic usage

Create your Lambda function script with this single line:

from cff.origin_request import handler

Advanced usage

To configure the handler, run configure() with a Configuration instance. For example:

from cff.origin_request import Configuration, configure, handler

configure(Configuration(...))
class cff.origin_request.Configuration(index: str = 'index.html')
index: str = 'index.html'

Document to serve when a directory is requested.

cff.origin_request.configure(config: cff.origin_request.Configuration) None

Configure the Origin Request handler.