Skip to content

Commit

Permalink
DOC: Add docstring for the public cache key generator. [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
Taher Chegini committed May 20, 2024
1 parent 98e367f commit 5637eac
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions pygeoogc/cache_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations

import hashlib
from typing import Any, Mapping, Sequence, Union
from typing import Any, Literal, Mapping, Sequence, Union

from multidict import MultiDict
from url_normalize import url_normalize
Expand Down Expand Up @@ -46,13 +46,32 @@ def _encode_dict(data: Any) -> bytes:


def create_request_key(
method: str,
method: Literal["GET", "POST", "get", "post"],
url: StrOrURL,
params: RequestParams = None,
data: Mapping[str, Any] | None = None,
json: Mapping[str, Any] | None = None,
) -> str:
"""Create a unique cache key based on request details."""
"""Create a unique cache key based on request details.
Parameters
----------
method : str
The HTTP method used in the request. Must be either "GET" or "POST".
url : str or yarl.URL
The URL of the request.
params : dict or list or str or None, optional
The query parameters of the request. Default is None.
data : dict or None, optional
The data of the request. Default is None.
json : dict or None, optional
The JSON data of the request. Default is None.
Returns
-------
str
The unique cache key based on the request details.
"""
# Normalize and filter all relevant pieces of request data
norm_url = _normalize_url_params(url, params)

Expand Down

0 comments on commit 5637eac

Please sign in to comment.