pip_services3_rpc.services.HttpResponseSender module
pip_services3_rpc.services.HttpResponseSender
HttpResponseSender implementation
- copyright
Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.
- license
MIT, see LICENSE for more details.
- class pip_services3_rpc.services.HttpResponseSender.HttpResponseSender
Bases:
object
Helper class that handles HTTP-based responses.
- static send_created_result(result: Any) Optional[str]
Creates a callback function that sends newly created object as JSON. That callack function call be called directly or passed as a parameter to business logic components.
If object is not null it returns 201 status code. For null results it returns 204 status code. If error occur it sends ErrorDescription with approproate status code.
- Parameters
result – an execution result or a promise with execution result
- Returns
JSON text response
- static send_deleted_result(result: Optional[Any] = None) Optional[str]
Creates a callback function that sends newly created object as JSON. That callack function call be called directly or passed as a parameter to business logic components.
If object is not null it returns 201 status code. For null results it returns 204 status code. If error occur it sends ErrorDescription with approproate status code.
- Parameters
result – an execution result or a promise with execution result
- Returns
JSON text response
- static send_empty_result(result: Optional[Any] = None) Optional[str]
Creates a callback function that sends an empty result with 204 status code. If error occur it sends ErrorDescription with approproate status code.
- Parameters
result –
- Returns
JSON text response
- static send_error(error: Any) str
Sends error serialized as ErrorDescription object and appropriate HTTP status code. If status code is not defined, it uses 500 status code.
- Parameters
error – an error object to be sent.
- Returns
HTTP response status
- static send_result(result: Any) Optional[str]
Creates a callback function that sends result as JSON object. That callack function call be called directly or passed as a parameter to business logic components.
If object is not null it returns 200 status code. For null results it returns 204 status code. If error occur it sends ErrorDescription with approproate status code.
- Parameters
result – an execution result
- Returns
JSON text response