pub struct InertiaHttpResponse {
pub status: u16,
pub headers: Vec<(String, String)>,
pub body: String,
pub content_type: &'static str,
}Expand description
Framework-agnostic HTTP response.
Convert this to your framework’s response type.
Fields§
§status: u16HTTP status code
headers: Vec<(String, String)>Response headers as (name, value) pairs
body: StringResponse body
content_type: &'static strContent type
Implementations§
Source§impl InertiaHttpResponse
impl InertiaHttpResponse
Sourcepub fn json(body: impl Into<String>) -> InertiaHttpResponse
pub fn json(body: impl Into<String>) -> InertiaHttpResponse
Create a JSON response with Inertia headers.
Sourcepub fn raw_json(body: impl Into<String>) -> InertiaHttpResponse
pub fn raw_json(body: impl Into<String>) -> InertiaHttpResponse
Create a raw JSON response without Inertia headers.
Used for JSON fallback when a non-Inertia client requests JSON.
Sourcepub fn html(body: impl Into<String>) -> InertiaHttpResponse
pub fn html(body: impl Into<String>) -> InertiaHttpResponse
Create an HTML response.
Sourcepub fn conflict(location: impl Into<String>) -> InertiaHttpResponse
pub fn conflict(location: impl Into<String>) -> InertiaHttpResponse
Create a 409 Conflict response for version mismatch.
Sourcepub fn status(self, status: u16) -> InertiaHttpResponse
pub fn status(self, status: u16) -> InertiaHttpResponse
Set the HTTP status code.
Sourcepub fn header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> InertiaHttpResponse
pub fn header( self, name: impl Into<String>, value: impl Into<String>, ) -> InertiaHttpResponse
Add a header to the response.
Sourcepub fn redirect(
location: impl Into<String>,
is_post_like: bool,
) -> InertiaHttpResponse
pub fn redirect( location: impl Into<String>, is_post_like: bool, ) -> InertiaHttpResponse
Create a redirect response for Inertia requests.
For POST/PUT/PATCH/DELETE requests, uses status 303 (See Other) to force the browser to follow the redirect with a GET request.
For GET requests, uses standard 302.
Trait Implementations§
Source§impl Clone for InertiaHttpResponse
impl Clone for InertiaHttpResponse
Source§fn clone(&self) -> InertiaHttpResponse
fn clone(&self) -> InertiaHttpResponse
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 InertiaHttpResponse
impl RefUnwindSafe for InertiaHttpResponse
impl Send for InertiaHttpResponse
impl Sync for InertiaHttpResponse
impl Unpin for InertiaHttpResponse
impl UnsafeUnpin for InertiaHttpResponse
impl UnwindSafe for InertiaHttpResponse
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: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more