Struct leptos_axum::ResponseOptions
source · pub struct ResponseOptions(pub Arc<RwLock<ResponseParts>>);
Expand description
Allows you to override details of the HTTP response like the status code and add Headers/Cookies.
ResponseOptions
is provided via context when you use most of the handlers provided in this
crate, including .leptos_routes
,
.leptos_routes_with_context
, handle_server_fns
, etc.
You can find the full set of provided context types in each handler function.
If you provide your own handler, you will need to provide ResponseOptions
via context
yourself if you want to access it via context.
ⓘ
#[server]
pub async fn get_opts() -> Result<(), ServerFnError> {
let opts = expect_context::<leptos_axum::ResponseOptions>();
Ok(())
}
Tuple Fields§
§0: Arc<RwLock<ResponseParts>>
Implementations§
source§impl ResponseOptions
impl ResponseOptions
sourcepub fn overwrite(&self, parts: ResponseParts)
pub fn overwrite(&self, parts: ResponseParts)
A simpler way to overwrite the contents of ResponseOptions
with a new ResponseParts
.
sourcepub fn set_status(&self, status: StatusCode)
pub fn set_status(&self, status: StatusCode)
Set the status of the returned Response.
sourcepub fn insert_header(&self, key: HeaderName, value: HeaderValue)
pub fn insert_header(&self, key: HeaderName, value: HeaderValue)
Insert a header, overwriting any previous value with the same key.
sourcepub fn append_header(&self, key: HeaderName, value: HeaderValue)
pub fn append_header(&self, key: HeaderName, value: HeaderValue)
Append a header, leaving any header with the same key intact.
Trait Implementations§
source§impl Clone for ResponseOptions
impl Clone for ResponseOptions
source§fn clone(&self) -> ResponseOptions
fn clone(&self) -> ResponseOptions
Returns a copy 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 moresource§impl Debug for ResponseOptions
impl Debug for ResponseOptions
source§impl Default for ResponseOptions
impl Default for ResponseOptions
source§fn default() -> ResponseOptions
fn default() -> ResponseOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ResponseOptions
impl !RefUnwindSafe for ResponseOptions
impl Send for ResponseOptions
impl Sync for ResponseOptions
impl Unpin for ResponseOptions
impl !UnwindSafe for ResponseOptions
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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