Struct prost_twirp::ServiceRequest
source · pub struct ServiceRequest<T: Message> {
pub uri: Uri,
pub method: Method,
pub version: Version,
pub headers: HeaderMap,
pub input: T,
}
Expand description
A request with HTTP info and a proto request payload object.
Fields§
§uri: Uri
The URI of the original request
When using a client, this will be overridden with the proper URI. It is only valuable for servers.
method: Method
The request method; should always be POST
.
version: Version
The HTTP version, rarely changed from the default.
headers: HeaderMap
The set of headers
Should always at least have Content-Type
. Clients will override Content-Length
on serialization.
input: T
The request body as a proto Message
, representing the arguments of the proto rpc.
Implementations§
source§impl<T: Message> ServiceRequest<T>
impl<T: Message> ServiceRequest<T>
sourcepub fn new(input: T) -> ServiceRequest<T>
pub fn new(input: T) -> ServiceRequest<T>
Create new service request with the given input object
This automatically sets the Content-Type
header as application/protobuf
.
sourcepub fn clone_with_input(&self, input: T) -> ServiceRequest<T>
pub fn clone_with_input(&self, input: T) -> ServiceRequest<T>
Copy this request with a different input value
source§impl<T: Message + Default + 'static> ServiceRequest<T>
impl<T: Message + Default + 'static> ServiceRequest<T>
sourcepub fn to_hyper_request(&self) -> Result<Request<Body>, ProstTwirpError>
pub fn to_hyper_request(&self) -> Result<Request<Body>, ProstTwirpError>
Serialize into a hyper request.
pub async fn from_hyper_request(
req: Request<Body>
) -> Result<ServiceRequest<T>, ProstTwirpError>
Trait Implementations§
source§impl<T: Message + Default + 'static> From<T> for ServiceRequest<T>
impl<T: Message + Default + 'static> From<T> for ServiceRequest<T>
source§fn from(v: T) -> ServiceRequest<T>
fn from(v: T) -> ServiceRequest<T>
Converts to this type from the input type.