update + htmx

This commit is contained in:
JMARyA 2024-12-22 18:37:45 +01:00
parent 40d69b61e1
commit 291949b8c6
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
8 changed files with 277 additions and 10 deletions

View file

@ -27,3 +27,19 @@ CREATE TABLE IF NOT EXISTS user_session (
FOREIGN KEY("user") REFERENCES users(username)
);
```
## HTMX
Based has a route for serving HTMX at `based::htmx::htmx_script_route` which you can include in your rocket `routes!`. The HTMX script will be available at `/assets/htmx.min.js`.
Additionally you can check if a requests originates from HTMX:
```rs
#[get("/")]
pub async fn index(ctx: RequestContext) -> StringRespopnse {
if ctx.is_htmx {
...
} else {
...
}
}
```