generic requests#

Implement generic request function with own logging and return functionality

class src.tetue_generic.generic_requests.GenReqConfiguration(request_timeout='30')[source]#

Configuration settings for generic HTTP requests.

async src.tetue_generic.generic_requests.generic_http_request(url, header, timeout)[source]#

Performs an asynchronous HTTP GET request and handles potential exceptions.

This function sends a GET request to the specified URL with given headers and timeout. It catches and logs common HTTP request exceptions using Loguru.

Parameters:
  • url (str) – The URL to send the GET request to.

  • header (dict) – A dictionary of HTTP headers to include in the request.

  • timeout (int) – The timeout duration for the request in seconds.

Returns:

The response object if the request is successful, or None if an exception occurs.

Return type:

requests.Response | None

Raises:

No exceptions are raised; they are caught and logged instead.

Logs:
  • HTTP errors

  • Connection timeout errors

  • General connection errors

Note

This function uses a global logger object for logging, which should be a configured Loguru logger instance.