labthings_fastapi.descriptors.endpoint

Module Contents

Classes

EndpointDescriptor

A descriptor to allow Things to easily add other endpoints

Data

HTTPMethod

API

labthings_fastapi.descriptors.endpoint.HTTPMethod

None

class labthings_fastapi.descriptors.endpoint.EndpointDescriptor(func: Callable, http_method: labthings_fastapi.descriptors.endpoint.HTTPMethod = 'get', path: Optional[str] = None, **kwargs: Mapping)

A descriptor to allow Things to easily add other endpoints

Initialization

__get__(obj: Optional[labthings_fastapi.thing.Thing], type=None) Union[typing_extensions.Self, Callable]

The function, bound to an object as for a normal method.

If obj is None, the descriptor is returned, so we can get the descriptor conveniently as an attribute of the class.

property name

The name of the wrapped function

property path

The path of the endpoint (relative to the Thing)

property title

A human-readable title

property description

A description of the endpoint

add_to_fastapi(app: fastapi.FastAPI, thing: labthings_fastapi.thing.Thing)

Add this function to a FastAPI app, bound to a particular Thing.