add
This commit is contained in:
20
users-events/app/ses_utils.py
Normal file
20
users-events/app/ses_utils.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from typing import Any, Iterator
|
||||
|
||||
from aws_lambda_powertools.utilities.data_classes.ses_event import SESMailHeader
|
||||
|
||||
|
||||
def get_header_value(
|
||||
headers: Iterator[SESMailHeader],
|
||||
header_name: str,
|
||||
*,
|
||||
default: Any = None,
|
||||
raise_on_missing: bool = True,
|
||||
) -> str:
|
||||
for header in headers:
|
||||
if header.name.lower() == header_name:
|
||||
return header.value
|
||||
|
||||
if raise_on_missing:
|
||||
raise ValueError(f'{header_name} not found.')
|
||||
|
||||
return default
|
||||
Reference in New Issue
Block a user