Skip to content

Module tipg.resources.response

tipg custom responses.

Functions

default

def default(
    obj
)

Instruct orjson what to do with types it does not natively serialize

orjsonDumps

def orjsonDumps(
    content: Any
)

Small wrapper function to run the orjson.dumps with the additional options we want

Classes

GeoJSONResponse

class GeoJSONResponse(
    content: 'typing.Any',
    status_code: 'int' = 200,
    headers: 'typing.Mapping[str, str] | None' = None,
    media_type: 'str | None' = None,
    background: 'BackgroundTask | None' = None
)

GeoJSON Response

Ancestors (in MRO)

  • tipg.resources.response.ORJSONResponse
  • starlette.responses.JSONResponse
  • starlette.responses.Response

Class variables

charset
media_type

Instance variables

headers

Methods

def delete_cookie(
    self,
    key: 'str',
    path: 'str' = '/',
    domain: 'str | None' = None,
    secure: 'bool' = False,
    httponly: 'bool' = False,
    samesite: "typing.Literal[('lax', 'strict', 'none')] | None" = 'lax'
) -> 'None'

init_headers

def init_headers(
    self,
    headers: 'typing.Mapping[str, str] | None' = None
) -> 'None'

render

def render(
    self,
    content: Any
) -> bytes

Render the content into a JSON response using orjson

def set_cookie(
    self,
    key: 'str',
    value: 'str' = '',
    max_age: 'int | None' = None,
    expires: 'datetime | str | int | None' = None,
    path: 'str | None' = '/',
    domain: 'str | None' = None,
    secure: 'bool' = False,
    httponly: 'bool' = False,
    samesite: "typing.Literal[('lax', 'strict', 'none')] | None" = 'lax'
) -> 'None'

ORJSONResponse

class ORJSONResponse(
    content: 'typing.Any',
    status_code: 'int' = 200,
    headers: 'typing.Mapping[str, str] | None' = None,
    media_type: 'str | None' = None,
    background: 'BackgroundTask | None' = None
)

Custom response handler for using orjson

Ancestors (in MRO)

  • starlette.responses.JSONResponse
  • starlette.responses.Response

Descendants

  • tipg.resources.response.GeoJSONResponse
  • tipg.resources.response.SchemaJSONResponse

Class variables

charset
media_type

Instance variables

headers

Methods

def delete_cookie(
    self,
    key: 'str',
    path: 'str' = '/',
    domain: 'str | None' = None,
    secure: 'bool' = False,
    httponly: 'bool' = False,
    samesite: "typing.Literal[('lax', 'strict', 'none')] | None" = 'lax'
) -> 'None'

init_headers

def init_headers(
    self,
    headers: 'typing.Mapping[str, str] | None' = None
) -> 'None'

render

def render(
    self,
    content: Any
) -> bytes

Render the content into a JSON response using orjson

def set_cookie(
    self,
    key: 'str',
    value: 'str' = '',
    max_age: 'int | None' = None,
    expires: 'datetime | str | int | None' = None,
    path: 'str | None' = '/',
    domain: 'str | None' = None,
    secure: 'bool' = False,
    httponly: 'bool' = False,
    samesite: "typing.Literal[('lax', 'strict', 'none')] | None" = 'lax'
) -> 'None'

SchemaJSONResponse

class SchemaJSONResponse(
    content: 'typing.Any',
    status_code: 'int' = 200,
    headers: 'typing.Mapping[str, str] | None' = None,
    media_type: 'str | None' = None,
    background: 'BackgroundTask | None' = None
)

Schema Response

Ancestors (in MRO)

  • tipg.resources.response.ORJSONResponse
  • starlette.responses.JSONResponse
  • starlette.responses.Response

Class variables

charset
media_type

Instance variables

headers

Methods

def delete_cookie(
    self,
    key: 'str',
    path: 'str' = '/',
    domain: 'str | None' = None,
    secure: 'bool' = False,
    httponly: 'bool' = False,
    samesite: "typing.Literal[('lax', 'strict', 'none')] | None" = 'lax'
) -> 'None'

init_headers

def init_headers(
    self,
    headers: 'typing.Mapping[str, str] | None' = None
) -> 'None'

render

def render(
    self,
    content: Any
) -> bytes

Render the content into a JSON response using orjson

def set_cookie(
    self,
    key: 'str',
    value: 'str' = '',
    max_age: 'int | None' = None,
    expires: 'datetime | str | int | None' = None,
    path: 'str | None' = '/',
    domain: 'str | None' = None,
    secure: 'bool' = False,
    httponly: 'bool' = False,
    samesite: "typing.Literal[('lax', 'strict', 'none')] | None" = 'lax'
) -> 'None'