Inertia.js for Rocket
inertia_rs
defines a succinct interface for creating Inertia.js apps in Rocket. It's comprised of two elements, Inertia<T>
, a Responder that's generic over T
, the Inertia component's properties, and VersionFairing
, which is responsible for asset version checks.
```rust
extern crate rocket;
use inertiars::{Inertia, VersionFairing}; use rocket::response::Responder; use rocketdyn_templates::Template;
struct Hello { secret: String, }
fn hello() -> Inertia
fn rocket() -> _ { rocket::build() .mount("/", routes![hello]) .attach(Template::fairing()) // Version fairing is configured with current asset version, and a // closure to generate the html template response .attach(VersionFairing::new("X2", |request, ctx| { Template::render("app", ctx).respond_to(request) })) }
```