Response helper
create_success(data=None, message=CREATED_MESSAGE)
Generate a JSON response with a 201 status code (Created).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
dict[Any, Any] | None
|
Optional data to include in the response body. |
None
|
message |
str
|
Optional message to include in the response. |
CREATED_MESSAGE
|
Returns:
Type | Description |
---|---|
Response
|
The JSON response. |
Source code in hestia/web/response_helper.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
forbidden_error(message=FORBIDDEN_MESSAGE)
Generate a JSON response with a 403 status code (Forbidden).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
Optional message to include in the response. |
FORBIDDEN_MESSAGE
|
Returns:
Type | Description |
---|---|
Response
|
The JSON response. |
Source code in hestia/web/response_helper.py
68 69 70 71 72 73 74 75 76 77 |
|
found(location)
Generate a redirect response with a 302 status code (Found).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location |
str
|
The URL to redirect to. |
required |
Returns:
Type | Description |
---|---|
RedirectResponse
|
The RedirectResponse. |
Source code in hestia/web/response_helper.py
102 103 104 105 106 107 108 109 |
|
moved_permanently(location)
Generate a redirect response with a 301 status code (Moved Permanently).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location |
str
|
The URL to redirect to. |
required |
Returns:
Type | Description |
---|---|
RedirectResponse
|
The RedirectResponse. |
Source code in hestia/web/response_helper.py
92 93 94 95 96 97 98 99 |
|
not_found_error(message=NOT_FOUND_MESSAGE)
Generate a JSON response with a 404 status code (Not Found).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
Optional message to include in the response. |
NOT_FOUND_MESSAGE
|
Returns:
Type | Description |
---|---|
Response
|
The JSON response. |
Source code in hestia/web/response_helper.py
56 57 58 59 60 61 62 63 64 65 |
|
success(data=None, message=SUCCESS_MESSAGE)
Generate a JSON response with a 200 status code (OK).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
dict[Any, Any] | None
|
Optional data to include in the response body. |
None
|
message |
str
|
Optional message to include in the response. |
SUCCESS_MESSAGE
|
Returns:
Type | Description |
---|---|
Response
|
The JSON response. |
Source code in hestia/web/response_helper.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
unauthorized_error(message=UNAUTHORIZED_MESSAGE)
Generate a JSON response with a 401 status code (Unauthorized).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
Optional message to include in the response. |
UNAUTHORIZED_MESSAGE
|
Returns:
Type | Description |
---|---|
Response
|
The JSON response. |
Source code in hestia/web/response_helper.py
80 81 82 83 84 85 86 87 88 89 |
|