Skip to main content

MethodView

Dispatches request methods to the corresponding instance methods. For example, if you implement a get method, it will be used to handle GET requests.

This can be useful for defining a REST API.

Attributes

AttributeTypeDescription
methodsmethods is automatically set based on the methods defined on the class.

Methods


dispatch_request()

@classmethod
def dispatch_request(
kwargs: t.Any
) - > ft.ResponseReturnValue

Dispatches the incoming request to the corresponding instance method based on the HTTP request method (e.g., 'GET' requests are handled by the 'get' method). If a 'HEAD' request is received and no specific 'head' method is defined, it falls back to the 'get' method.

Parameters

NameTypeDescription
kwargst.AnyArbitrary keyword arguments extracted from the URL routing, which are passed directly to the HTTP method handler (e.g., 'get', 'post').

Returns

TypeDescription
ft.ResponseReturnValueThe return value from the invoked HTTP method handler, which is typically a response object or a value that can be converted into one.