faster_sam.routing module

class faster_sam.routing.APIRoute(
path,
endpoint,
*args,
**kwargs,
)

Bases: APIRoute

Extends FastAPI Router class used to describe path operations.

This custom router class receives the endpoint parameter as a string with the full module path instead of the actual callable.

class faster_sam.routing.ApiGatewayResponse(
data,
)

Bases: Response

Represents an API Gateway HTTP response.

async faster_sam.routing.event_builder(
request,
)

Builds an event of type aws_proxy from API Gateway.

It uses the given request object to fill the event details.

Parameters:

request (Request) – A request object.

Returns:

An aws_proxy event.

Return type:

Dict[str, Any]

faster_sam.routing.handler(
func,
)

Returns a wrapper function.

The returning function converts a request object into a AWS proxy event, then the event is passed to the handler function, finally the function result is converted to a response object.

Parameters:

func (Handler) – A callable object.

Returns:

An async function, which accepts a single request argument and return a response.

Return type:

Endpoint

faster_sam.routing.import_handler(
path,
)

Returns a callable object from the given module path.

Parameters:

path (str) – Full module path.

Returns:

A callable object.

Return type:

Handler