Response Headers
Auto-generated documentation for moona.http.response_headers module.
auto_content_length
@handle_func_sync
def auto_content_length(ctx: HTTPContext) -> HTTPContext:
Sets “Content-Length” to current response body.
If body is None
than 0 length is set.
Arguments
ctx
HTTPContext - to set header to.
See also
content_length
def content_length(value: int) -> HTTPHandler:
HTTPHandler
that sets “Content-Length` response header.
Arguments
value
int - of header
See also
content_type
def content_type(value: str):
HTTPHandler
that sets “Content-Type” response header.
Arguments
value
str - of header.
Returns
HTTPHandler
- handler.
content_type_application_json
def content_type_application_json(
nxt: HTTPFunc,
ctx: HTTPContext,
) -> future[HTTPContext | None]:
Sets “Content-Type: application/json” response header.
Arguments
nxt
HTTPFunc - to run next.ctx
HTTPContext - to process.
Returns
future[HTTPContext | None]: result |
See also
content_type_text_plain
def content_type_text_plain(
nxt: HTTPFunc,
ctx: HTTPContext,
) -> future[HTTPContext | None]:
Sets “Content-Type: text/plain” response header.
Arguments
nxt
HTTPFunc - to run next.ctx
HTTPContext - to process
Returns
future[HTTPContext | None]: result. |
See also
header
@handler2
def header(
name: str,
value: str,
nxt: HTTPFunc,
ctx: HTTPContext,
) -> future[HTTPContext | None]:
HTTPHandler
that sets response header.
Arguments
name
str - of header.value
str - of header.nxt
HTTPFunc - to run next.ctx
HTTPContext - to process.
Returns
future[HTTPContext | None]: result. |