update
This commit is contained in:
parent
a89c566120
commit
2097bd1cca
4 changed files with 81 additions and 27 deletions
35
examples/basic.rs
Normal file
35
examples/basic.rs
Normal 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])
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue