pub struct Request { /* private fields */ }Expand description
A tiny_http-like request handed to your loop.
Implementations§
Source§impl Request
impl Request
pub fn url(&self) -> &str
pub fn method(&self) -> &Method
pub fn headers(&self) -> &HeaderMap
pub fn body(&self) -> &Bytes
pub fn respond(self, response: Response) -> Result<(), RespondError>
Sourcepub fn fake(method: &Method, url: &str, body: &[u8]) -> Self
pub fn fake(method: &Method, url: &str, body: &[u8]) -> Self
Creates a fake Request for testing purposes.
This is useful for simulating incoming HTTP requests without starting a server.
§Arguments
method- The HTTP method (e.g.,Method::GET).url- The request URL path (e.g.,"/signup").body- The request body as bytes.
§Example
use async_tiny::{Request, Method};
let req = Request::fake(&Method::POST, "/submit", b"username=alice");Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Request
impl !RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl !UnwindSafe for Request
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