You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
645 B
24 lines
645 B
from __future__ import annotations
|
|
|
|
from typing import Dict
|
|
|
|
CONTENT_TYPE = ("Content-Type", "application/json; charset=utf-8")
|
|
AUTHORIZATION = ("Authorization", "Bearer %s")
|
|
X_REQUEST_ID = ("X-Request-Id", "%s")
|
|
|
|
|
|
def create_headers(
|
|
token: str | None = None,
|
|
with_content: bool = False,
|
|
request_id: str | None = None,
|
|
) -> Dict[str, str]:
|
|
headers: Dict[str, str] = {}
|
|
|
|
if token:
|
|
headers.update([(AUTHORIZATION[0], AUTHORIZATION[1] % token)])
|
|
if with_content:
|
|
headers.update([CONTENT_TYPE])
|
|
if request_id:
|
|
headers.update([(X_REQUEST_ID[0], X_REQUEST_ID[1] % request_id)])
|
|
|
|
return headers
|
|
|