feat(atward): Add an index page with setup instructions

Adds an index page that is rendered when there is no query parameter
in the URL. This means that going to at.tvl.fyi / atward.tvl.fyi
yields an actually useful page.

Change-Id: I018973a3c3e8b7b7167876fa99f34a008a17a4f2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3104
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
Vincent Ambo 2021-05-11 16:46:01 +02:00 committed by tazjin
parent 259cbfd0b2
commit 99d11bef5f
2 changed files with 84 additions and 1 deletions

View file

@ -113,6 +113,14 @@ fn dispatch(handlers: &[Handler], query: &Query) -> Option<String> {
None
}
/// Render the atward index page which gives users some information
/// about how to use the service.
fn index() -> Response {
Response::html(include_str!("index.html"))
}
/// Render the fallback page which informs users that their query is
/// unsupported.
fn fallback() -> Response {
Response::text("error for emphasis that i am angery and the query whimchst i angery atward")
.with_status_code(404)
@ -127,7 +135,7 @@ fn main() {
rouille::log(&request, std::io::stderr(), || {
let query = match Query::from_request(&request) {
Some(q) => q,
None => return fallback(),
None => return index(),
};
match dispatch(&queries, &query) {