pub struct RequestFactory { /* private fields */ }Expand description
Factory for creating test HTTP requests with minimal boilerplate.
§Example
ⓘ
use fastapi_core::fixtures::RequestFactory;
// Simple GET
let req = RequestFactory::get("/users").build();
// POST with JSON body and auth
let req = RequestFactory::post("/items")
.json(&Item { name: "Widget" })
.bearer_token("token123")
.header("X-Request-Id", "abc")
.build();Implementations§
Source§impl RequestFactory
impl RequestFactory
Sourcepub fn new(method: Method, path: impl Into<String>) -> Self
pub fn new(method: Method, path: impl Into<String>) -> Self
Create a new request factory with the given method and path.
Sourcepub fn query_params<I, K, V>(self, params: I) -> Self
pub fn query_params<I, K, V>(self, params: I) -> Self
Add query parameters from an iterator.
Sourcepub fn version(self, version: HttpVersion) -> Self
pub fn version(self, version: HttpVersion) -> Self
Set the HTTP version.
Sourcepub fn content_type(self, content_type: impl AsRef<str>) -> Self
pub fn content_type(self, content_type: impl AsRef<str>) -> Self
Set the Content-Type header.
Sourcepub fn bearer_token(self, token: impl AsRef<str>) -> Self
pub fn bearer_token(self, token: impl AsRef<str>) -> Self
Set a Bearer token for Authorization.
Sourcepub fn basic_auth(
self,
username: impl AsRef<str>,
password: impl AsRef<str>,
) -> Self
pub fn basic_auth( self, username: impl AsRef<str>, password: impl AsRef<str>, ) -> Self
Set Basic auth credentials.
Trait Implementations§
Source§impl Clone for RequestFactory
impl Clone for RequestFactory
Source§fn clone(&self) -> RequestFactory
fn clone(&self) -> RequestFactory
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 RequestFactory
impl RefUnwindSafe for RequestFactory
impl Send for RequestFactory
impl Sync for RequestFactory
impl Unpin for RequestFactory
impl UnwindSafe for RequestFactory
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).