apifrom.core.request ==================== Request module for APIFromAnything. This module defines the Request class that represents an HTTP request and provides methods for accessing request data. .. py:currentmodule:: apifrom.core.request Overview -------- **Classes** * :py:class:`Request` Classes ------- .. py:class:: Request(request = None, path_params = None, method = None, path = None, query_params = None, headers = None, body = None, client_ip = None) Request class for APIFromAnything. This class wraps a Starlette request and provides methods for accessing request data in a convenient way. .. attribute:: _request The underlying Starlette request. .. attribute:: path_params Path parameters extracted from the URL. .. attribute:: query_params Query parameters extracted from the URL. .. attribute:: headers HTTP headers. .. attribute:: method HTTP method. .. attribute:: path Request path. .. attribute:: _body Cached request body. Initialize a new Request instance. :param request: The underlying Starlette request. :param path_params: Path parameters extracted from the URL. :param method: The HTTP method. :param path: The request path. :param query_params: Query parameters. :param headers: HTTP headers. :param body: Request body. :param client_ip: Client IP address. .. :: state .. method:: __getattr__(name) Get an attribute from the underlying request. :param name: The name of the attribute. :returns: The attribute value. :raises AttributeError: If the attribute is not found. .. method:: body() :async: Get the request body. :returns: The request body as bytes. .. method:: form() :async: Get the request body as form data. :returns: The request body parsed as form data. .. method:: get_param(name, default = None) Get a parameter from the request. This method looks for the parameter in path parameters, query parameters, and then the request body (in that order). :param name: The name of the parameter. :param default: The default value to return if the parameter is not found. :returns: The parameter value, or the default value if not found. .. method:: json() :async: Get the request body as JSON. :returns: The request body parsed as JSON. :raises ValueError: If the request body is not valid JSON.