Skip to main content

rustio_core/
defaults.rs

1use crate::error::Error;
2use crate::http::{Request, Response, html, text};
3use crate::router::{Params, Router};
4
5const HOME_HTML: &str = include_str!("../assets/home.html");
6
7pub fn homepage() -> Response {
8    html(HOME_HTML)
9}
10
11pub fn admin_placeholder() -> Response {
12    text("RustIO admin — coming soon.")
13}
14
15pub fn docs_placeholder() -> Response {
16    text("RustIO docs — coming soon.")
17}
18
19pub fn with_defaults(router: Router) -> Router {
20    router
21        .get("/", |_req: Request, _p: Params| async {
22            Ok::<Response, Error>(homepage())
23        })
24        .get("/admin", |_req: Request, _p: Params| async {
25            Ok::<Response, Error>(admin_placeholder())
26        })
27        .get("/docs", |_req: Request, _p: Params| async {
28            Ok::<Response, Error>(docs_placeholder())
29        })
30}