This commit is contained in:
JMARyA 2024-12-24 02:12:16 +01:00
parent a89c566120
commit 2097bd1cca
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
4 changed files with 81 additions and 27 deletions

35
examples/basic.rs Normal file
View file

@ -0,0 +1,35 @@
use based::request::{RequestContext, StringResponse};
use based::{
get_pg,
page::{Shell, render_page},
};
use maud::html;
use rocket::get;
use rocket::routes;
#[get("/")]
pub async fn index_page(ctx: RequestContext) -> StringResponse {
let content = html!(
h1 { "Hello World!" };
);
render_page(
content,
"Hello World",
ctx,
&Shell::new(html! {}, html! {}, Some(String::new())),
)
.await
}
#[rocket::launch]
async fn launch() -> _ {
// Logging
env_logger::init();
// Database
let pg = get_pg!();
// sqlx::migrate!("./migrations").run(pg).await.unwrap();
rocket::build().mount("/", routes![index_page])
}