This commit is contained in:
Pascal Engélibert 2026-02-13 22:49:30 +01:00
commit 37eaccd80e
6 changed files with 160 additions and 45 deletions

View file

@ -1,5 +1,4 @@
use std::collections::HashMap;
use askama::Template;
use trillium::{Conn, Handler};
use trillium_router::{Router, RouterConnExt};
@ -8,23 +7,33 @@ pub async fn hello_world(conn: Conn) -> Conn {
}
pub fn make_router() -> impl Handler {
(trillium_caching_headers::CachingHeaders::new(),
trillium_static_compiled::static_compiled!("./static").with_index_file("index.html"),
(
trillium_caching_headers::CachingHeaders::new(),
//trillium_static_compiled::static_compiled!("./static").with_index_file("index.html"),
Router::new()
.post("/fetch", |mut conn: Conn| async move {
if let Ok(request_body) = conn.request_body().await.with_max_len(8192).await {
let mut repo_url = None;
for (key, val) in form_urlencoded::parse(request_body.as_bytes()) {
if key == "repo-url" {
repo_url = Some(val);
.get("/", |conn: Conn| async move {
conn.ok(crate::templates::Home {}.render().unwrap())
})
.post("/fetch", |mut conn: Conn| async move {
if let Ok(request_body) = conn.request_body().await.with_max_len(8192).await {
let mut repo_url = None;
for (key, val) in form_urlencoded::parse(request_body.as_bytes()) {
if key == "repo-url" {
repo_url = Some(val);
}
}
let Some(repo_url) = repo_url else {
return conn.ok("Missing arg");
};
}
let Some(repo_url) = repo_url else {
return conn.ok("Missing arg");
};
}
//let planet = conn.param("planet").unwrap();
let response_body = format!("hello");
conn.ok(response_body)
}))
//let planet = conn.param("planet").unwrap();
conn.ok(crate::templates::Home {}.render().unwrap())
})
.get("/r/:hash", |conn: Conn| async move {
conn.ok(crate::templates::Home {}.render().unwrap())
})
.get("/e/:secret", |conn: Conn| async move {
conn.ok(crate::templates::Home {}.render().unwrap())
}),
)
}