pub struct HttpRequest {
pub method: HttpMethod,
pub path: String,
pub headers: HashMap<String, String>,
pub body: Vec<u8>,
pub query: HashMap<String, String>,
}Expand description
Incoming HTTP request.
Fields§
§method: HttpMethodHTTP method.
path: StringRequest path (e.g., “/mcp/v1”).
headers: HashMap<String, String>Request headers.
body: Vec<u8>Request body.
query: HashMap<String, String>Query parameters.
Implementations§
Source§impl HttpRequest
impl HttpRequest
Sourcepub fn new(method: HttpMethod, path: impl Into<String>) -> HttpRequest
pub fn new(method: HttpMethod, path: impl Into<String>) -> HttpRequest
Creates a new HTTP request.
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> HttpRequest
pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> HttpRequest
Adds a header.
Sourcepub fn with_query(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> HttpRequest
pub fn with_query( self, name: impl Into<String>, value: impl Into<String>, ) -> HttpRequest
Adds a query parameter.
Sourcepub fn content_type(&self) -> Option<&str>
pub fn content_type(&self) -> Option<&str>
Gets the Content-Type header.
Gets the Authorization header.
Sourcepub fn json<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
pub fn json<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
Parses the body as JSON.
Trait Implementations§
Source§impl Clone for HttpRequest
impl Clone for HttpRequest
Source§fn clone(&self) -> HttpRequest
fn clone(&self) -> HttpRequest
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HttpRequest
impl RefUnwindSafe for HttpRequest
impl Send for HttpRequest
impl Sync for HttpRequest
impl Unpin for HttpRequest
impl UnwindSafe for HttpRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).