sunday_slate/web/
redirect.rs1use super::is_htmx;
2use axum::http::StatusCode;
3use axum::http::request::Parts;
4use axum::response::{IntoResponse, Redirect, Response};
5use axum_htmx::HxRedirect;
6
7pub fn redirect(htmx: bool, location: impl Into<String>) -> Response {
8 let location = location.into();
9 if htmx {
10 (HxRedirect(location), StatusCode::OK).into_response()
11 } else {
12 Redirect::to(&location).into_response()
13 }
14}
15
16pub fn redirect_parts(parts: &Parts, location: &str) -> Response {
17 redirect(is_htmx(&parts.headers), location)
18}