~gheartsfield/rasah

rust-axum-sqlx-askama-htmx app template
78a37b3d — Greg Heartsfield 3 months ago
setup db module
fc2dda62 — Greg Heartsfield 3 months ago
static file serving
4d551470 — Greg Heartsfield 3 months ago
custom error type

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~gheartsfield/rasah
read/write
git@git.sr.ht:~gheartsfield/rasah

You can also use your local clone with git send-email.

The goal of this project is to make a proof-of-concept for the combination of Rust, Axum, Sqlx, Askama, and HTMX for web applications.

We want a web application that supports stateful sessions, database backend, and eventually single-sign-on with KeyCloak/OIDC.

#Hello World (Axum)

Print hello world to the root (/) path with pure Rust/Axum.

cargo add tokio --features=full
cargo add axum

Latest at this point is Axum v0.7.9, and Tokio v1.42.0.

#Hello World (Axum + Askama)

Print hello world from an Askama template.

cargo add aksama aksama_axum

Latest version of aksama is v0.12.1, aksama_axum is v0.4.0.

We'll also add hyper to be able to access HTTP status codes.

cargo add hyper

Latest hyper is v1.5.1

#Hello World with Error Handling (+ thiserror)

Add some custom error handling functionality, using thiserror, as well as static file serving (images, CSS, etc.).

cargo add thiserror serde -F serde/derive

Now when you hit a page other than /, you get the 404 template.

Using version v2.0.6 of thiserror, and v1.0.216 of serde.

#Static File Serving (+ tower-http)

cargo add tower-http -F fs

Using tower-http v0.6.2.

#Hello World (Axum + Askama + Sqlx)

Initialize a database if one does not exist.

Print hello world from a database query.

#Add the libraries

cargo add sqlx --features "sqlite runtime-tokio"

Version v0.8.2 used.

#Create a database module & type

This will hold all our DB functionality.

Add db.rs

#Hello World (Axum + Askama + Sqlx + HTMX)

Use HTMX to replace a button with content from a database query.

Do not follow this link