summaryrefslogtreecommitdiff
path: root/venv/lib/python3.11/site-packages/litestar/enums.py
blob: a660228c9df382a51a7cf2be1857eaab70bb9430 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from enum import Enum

__all__ = (
    "CompressionEncoding",
    "HttpMethod",
    "MediaType",
    "OpenAPIMediaType",
    "ParamType",
    "RequestEncodingType",
    "ScopeType",
)


class HttpMethod(str, Enum):
    """An Enum for HTTP methods."""

    DELETE = "DELETE"
    GET = "GET"
    HEAD = "HEAD"
    OPTIONS = "OPTIONS"
    PATCH = "PATCH"
    POST = "POST"
    PUT = "PUT"


class MediaType(str, Enum):
    """An Enum for ``Content-Type`` header values."""

    JSON = "application/json"
    MESSAGEPACK = "application/x-msgpack"
    HTML = "text/html"
    TEXT = "text/plain"
    CSS = "text/css"
    XML = "application/xml"


class OpenAPIMediaType(str, Enum):
    """An Enum for OpenAPI specific response ``Content-Type`` header values."""

    OPENAPI_YAML = "application/vnd.oai.openapi"
    OPENAPI_JSON = "application/vnd.oai.openapi+json"


class RequestEncodingType(str, Enum):
    """An Enum for request ``Content-Type`` header values designating encoding formats."""

    JSON = "application/json"
    MESSAGEPACK = "application/x-msgpack"
    MULTI_PART = "multipart/form-data"
    URL_ENCODED = "application/x-www-form-urlencoded"


class ScopeType(str, Enum):
    """An Enum for the 'http' key stored under Scope.

    Notes:
        - ``asgi`` is used by Litestar internally and is not part of the specification.
    """

    HTTP = "http"
    WEBSOCKET = "websocket"
    ASGI = "asgi"


class ParamType(str, Enum):
    """An Enum for the types of parameters a request can receive."""

    PATH = "path"
    QUERY = "query"
    COOKIE = "cookie"
    HEADER = "header"


class CompressionEncoding(str, Enum):
    """An Enum for supported compression encodings."""

    GZIP = "gzip"
    BROTLI = "br"


class ASGIExtension(str, Enum):
    """ASGI extension keys: https://asgi.readthedocs.io/en/latest/extensions.html"""

    WS_DENIAL = "websocket.http.response"
    SERVER_PUSH = "http.response.push"
    ZERO_COPY_SEND_EXTENSION = "http.response.zerocopysend"
    PATH_SEND = "http.response.pathsend"
    TLS = "tls"
    EARLY_HINTS = "http.response.early_hint"
    HTTP_TRAILERS = "http.response.trailers"