duck.contrib.responses.simple_responseΒΆ
This module provides a shortcut to create a simple response with a given response class and icon link.
Module ContentsΒΆ
FunctionsΒΆ
Transforms a basic response like HttpServerErrorResponse into a nicer simple response. |
|
Transforms a basic response like HttpServerErrorResponse into a nicer simple response. |
DataΒΆ
APIΒΆ
- duck.contrib.responses.simple_response.FAVICONΒΆ
None
- exception duck.contrib.responses.simple_response.SimpleResponseErrorΒΆ
Bases:
ExceptionSimple response related errors.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- duck.contrib.responses.simple_response._make_simple_response(response_class: Type[duck.http.response.HttpResponse], title: str = None, heading: str = None, body: str = None, icon_link: str = None, icon_type='image/png') duck.http.response.HttpResponseΒΆ
Transforms a basic response like HttpServerErrorResponse into a nicer simple response.
- Parameters:
response_class β The response class to be transformed.
title β The title of the response, If not provided, response.status_message is used (optional).
heading β The heading of the response. If not provided, response.status_message is used (optional).
body β The body of the response. If not provided, response.status_explanation is used (optional).
icon_link β The link to the icon (optional).
icon_type β The type of the icon (optional).
- Raises:
SimpleResponseError β If the response class is not a subclass of HttpResponse.
SimpleResponseError β If the icon type is not provided when an icon link is provided.
- Returns:
The transformed response.
- Return type:
- duck.contrib.responses.simple_response._simple_response(response_class: Type[duck.http.response.HttpResponse], title: str = None, heading: str = None, body: str = None, icon_link=FAVICON, icon_type='image/png') duck.http.response.HttpResponseΒΆ
Transforms a basic response like HttpServerErrorResponse into a nicer simple response.
- Parameters:
response_class β The response class to be transformed.
title β The title of the response, If not provided, response.status_message is used (optional).
heading β The heading of the response. If not provided, response.status_message is used (optional).
body β The body of the response. If not provided, response.status_explanation is used (optional).
icon_link β The link to the icon (optional).
icon_type β The type of the icon (optional).
- Raises:
SimpleResponseError β If the response class is not a subclass of HttpResponse.
SimpleResponseError β If the icon type is not provided when an icon link is provided.
- Returns:
The transformed response.
- Return type: