robertwayne / axum-htmx

A set of htmx extractors, responders, and request guards for axum.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HxRequestGuardLayer should take an (optional) redirect route

robertwayne opened this issue · comments

commented

Probably like:

use axum::Router;
use axum_htmx::HxRequestGuardLayer;

fn protected_router() -> Router {
    Router::new()
        .layer(HxRequestGuardLayer::new().redirect_on_failure("/"))
}

EDIT: Possible that this could be default behavior, but it comes with the assumption that "/" will always resolve in a meaningful way, which may not (?) be the case. Could take an Option<&str> in the new fn to force this instead.