pub struct HxRedirect(pub String);Expand description
Response telling htmx to load another page: 200 OK with the HX-Redirect header.
htmx follows a plain 303 inside the XHR and swaps the result into the
target, which is wrong when an inline widget (a modal, an inline edit
form) should end on a whole new page. HX-Redirect makes htmx do a full
browser navigation instead (Loco’s redirect_with_header_key). Only for
requests where Htmx is true: other clients ignore the header, so
answer them with Redirect::to. A
target that is not a valid header value falls back to /.
§Examples
use axum::response::IntoResponse;
use ocre::HxRedirect;
let response = HxRedirect("/posts/7".to_owned()).into_response();
assert_eq!(response.status(), 200);
assert_eq!(response.headers()["hx-redirect"], "/posts/7");Tuple Fields§
§0: StringTrait Implementations§
Source§impl Clone for HxRedirect
impl Clone for HxRedirect
Source§fn clone(&self) -> HxRedirect
fn clone(&self) -> HxRedirect
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 HxRedirect
impl Debug for HxRedirect
impl Eq for HxRedirect
Source§impl IntoResponse for HxRedirect
impl IntoResponse for HxRedirect
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Create a response.
Source§impl PartialEq for HxRedirect
impl PartialEq for HxRedirect
Source§fn eq(&self, other: &HxRedirect) -> bool
fn eq(&self, other: &HxRedirect) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for HxRedirect
Auto Trait Implementations§
impl Freeze for HxRedirect
impl RefUnwindSafe for HxRedirect
impl Send for HxRedirect
impl Sync for HxRedirect
impl Unpin for HxRedirect
impl UnsafeUnpin for HxRedirect
impl UnwindSafe for HxRedirect
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T, S> Handler<IntoResponseHandler, S> for T
impl<T, S> Handler<IntoResponseHandler, S> for T
§fn call(
self,
_req: Request<Body>,
_state: S,
) -> <T as Handler<IntoResponseHandler, S>>::Future
fn call( self, _req: Request<Body>, _state: S, ) -> <T as Handler<IntoResponseHandler, S>>::Future
Call the handler with the given request.
§fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
Apply a [
tower::Layer] to the handler. Read more§fn with_state(self, state: S) -> HandlerService<Self, T, S>
fn with_state(self, state: S) -> HandlerService<Self, T, S>
Convert the handler into a [
Service] by providing the state§impl<H, T> HandlerWithoutStateExt<T> for Hwhere
H: Handler<T, ()>,
impl<H, T> HandlerWithoutStateExt<T> for Hwhere
H: Handler<T, ()>,
§fn into_service(self) -> HandlerService<H, T, ()>
fn into_service(self) -> HandlerService<H, T, ()>
Convert the handler into a [
Service] and no state.§fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
Convert the handler into a
MakeService and no state. Read more