more work
This commit is contained in:
parent
e4fcbe92cf
commit
02031f9062
|
@ -26,3 +26,7 @@ pub async fn signalboost(state: Arc<State>) -> Result<impl Reply, Rejection> {
|
|||
let state = state.clone();
|
||||
Response::builder().html(|o| templates::signalboost_html(o, state.signalboost.clone()))
|
||||
}
|
||||
|
||||
pub async fn not_found(path: String) -> Result<impl Reply, Rejection> {
|
||||
Response::builder().html(|o| templates::notfound_html(o, path))
|
||||
}
|
||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -27,6 +27,8 @@ async fn main() -> Result<()> {
|
|||
.into(),
|
||||
)?);
|
||||
|
||||
let healthcheck = warp::get().and(warp::path(".within").and(warp::path("health")).map(|| "OK"));
|
||||
|
||||
let routes = warp::get()
|
||||
.and(path::end().and_then(handlers::index))
|
||||
.or(warp::path!("contact").and_then(handlers::contact))
|
||||
|
@ -40,9 +42,21 @@ async fn main() -> Result<()> {
|
|||
|
||||
let files = warp::path("static")
|
||||
.and(warp::fs::dir("./static"))
|
||||
.or(warp::path("css").and(warp::fs::dir("./css")));
|
||||
.or(warp::path("css").and(warp::fs::dir("./css")))
|
||||
.or(warp::path("sw.js").and(warp::fs::file("./static/js/sw.js")))
|
||||
.or(warp::path("robots.txt").and(warp::fs::file("./static/robots.txt")));
|
||||
|
||||
let site = routes.or(files).with(warp::log(APPLICATION_NAME));
|
||||
let site = routes
|
||||
.or(files)
|
||||
.map(|reply| {
|
||||
warp::reply::with_header(
|
||||
reply,
|
||||
"X-Hacker",
|
||||
"If you are reading this, check out /signalboost to find people for your team",
|
||||
)
|
||||
})
|
||||
.or(healthcheck)
|
||||
.with(warp::log(APPLICATION_NAME));
|
||||
|
||||
warp::serve(site).run(([127, 0, 0, 1], 3030)).await;
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
@use super::{header_html, footer_html};
|
||||
|
||||
@(why: String)
|
||||
|
||||
@:header_html(Some("Error"), None)
|
||||
|
||||
<h1>Error</h1>
|
||||
|
||||
<code><pre>@why</pre></code>
|
||||
|
||||
<p>You could try to <a href="/">go home</a> or <a href="https://github.com/Xe/site/issues/new">report this issue</a> so it can be fixed.</p>
|
||||
|
||||
@:footer_html()
|
|
@ -0,0 +1,11 @@
|
|||
@use super::{header_html, footer_html};
|
||||
|
||||
@(path: String)
|
||||
|
||||
@:header_html(Some("Not Found"), None)
|
||||
|
||||
<h1>Not Found</h1>
|
||||
|
||||
<p>The path at <code>@path</code> could not be found. If you expected this path to exist, please <a href="https://github.com/Xe/site/issues/new">report this issue</a> so it can be fixed.</p>
|
||||
|
||||
@:footer_html()
|
Loading…
Reference in New Issue