Module util

Source
Expand description

HTTP utilities for request/response conversion.

Functions§

notification_sse_response
Converts a NotificationStream<Response> to an HttpResponse<Body> so server-side events can be produced by the HTTP server. Can be useful for implementing ResponseHttpConvert::to_http_response.
notification_sse_stream
Converts an HttpResponse<Body> to a NotificationStream<Response> so server-side events can be consumed by the HTTP client. Can be useful for implementing ResponseHttpConvert::from_http_response.
parse_request
Deserializes the body of HttpRequest<Body> into T. Returns a “bad request” error if JSON deserialization fails, and returns an “internal” error if raw data retrieval from the request fails. Can be useful for implementing RequestHttpConvert::from_http_request.
parse_response
Deserializes the body of HttpResponse<Body> into T. Returns a “bad request” error if JSON deserialization fails, and returns an “internal” error if raw data retrieval from the request fails. Can be useful for implementing ResponseHttpConvert::from_http_response.
serialize_to_http_request
Serializes T into HttpRequest<Body>. Returns an “internal” error if JSON serialization fails. Can be useful for implementing RequestHttpConvert::to_http_request.
serialize_to_http_response
Serializes T into HttpResponse<Body>. Returns an “internal” error if JSON serialization fails. Can be useful for implementing ResponseHttpConvert::to_http_response.
validate_method
Compares the request method with an expected method and returns ProtocolErrorType::HttpMethodNotAllowed if there is a mismatch. Can be useful for implementing RequestHttpConvert::from_http_request.