mirror of
https://github.com/Xevion/dynamic-preauth.git
synced 2025-12-10 20:07:05 -06:00
Remove templating
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -1,7 +1,6 @@
|
||||
use std::collections::HashMap;
|
||||
use std::path;
|
||||
|
||||
use askama::Template;
|
||||
use salvo::http::HeaderValue;
|
||||
use salvo::logging::Logger;
|
||||
|
||||
@@ -48,22 +47,6 @@ fn search(buf: &[u8], pattern: &[u8], start_index: usize) -> Option<usize> {
|
||||
None
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "index.html")]
|
||||
struct IndexTemplate<'a> {
|
||||
available: Vec<&'a str>,
|
||||
}
|
||||
|
||||
#[handler]
|
||||
async fn index(res: &mut Response, depot: &Depot) {
|
||||
let state = depot.obtain::<State>().unwrap();
|
||||
|
||||
let index_tmpl = IndexTemplate {
|
||||
available: state.executables.keys().map(|x| *x).collect(),
|
||||
};
|
||||
res.render(Text::Html(index_tmpl.render().unwrap()));
|
||||
}
|
||||
|
||||
#[handler]
|
||||
async fn download(depot: &mut Depot, req: &mut Request, res: &mut Response) {
|
||||
let article_id = req.param::<String>("id").unwrap();
|
||||
@@ -160,7 +143,6 @@ async fn main() {
|
||||
let router = Router::new()
|
||||
.hoop(affix_state::inject(state))
|
||||
.push(Router::with_path("download/<id>").get(download))
|
||||
.push(Router::new().get(index))
|
||||
.push(Router::with_path("<**path>").get(StaticDir::new(["./public"])));
|
||||
|
||||
let service = Service::new(router).hoop(Logger::new());
|
||||
|
||||
Reference in New Issue
Block a user