forked from mtusi2026/mtusi2026lab5
Принимать файл отдельно от обработки, чтобы задание переживало рестарт и повторную доставку.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
"""API errors that map onto the contract body. Details never include SQL or secrets."""
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
class ApiError(Exception):
|
||||
def __init__(self, status: int, code: str, message: str, headers: dict | None = None):
|
||||
super().__init__(message)
|
||||
self.status = status
|
||||
self.code = code
|
||||
self.message = message
|
||||
self.headers = headers or {}
|
||||
|
||||
|
||||
def unauthorized(kind: str) -> ApiError:
|
||||
if kind == "basic":
|
||||
header = 'Basic realm="messenger", charset="UTF-8"'
|
||||
else:
|
||||
header = 'Bearer realm="messenger"'
|
||||
return ApiError(401, "unauthorized", "Требуется действительная аутентификация", {"WWW-Authenticate": header})
|
||||
Reference in New Issue
Block a user