aboutsummaryrefslogtreecommitdiffstats
path: root/src/handlers.rs
diff options
context:
space:
mode:
authorYigit Sever2021-04-15 00:32:28 +0300
committerYigit Sever2021-04-15 00:32:28 +0300
commit868c9714d852761bf3ee389e4730098e2bc59b46 (patch)
tree257b0bea537666d0656504208a4e81666fbf908b /src/handlers.rs
parentcc1426f6d4e811fdb26a8ba5cff487ba63d0a6b5 (diff)
downloadgradecoin-868c9714d852761bf3ee389e4730098e2bc59b46.tar.gz
gradecoin-868c9714d852761bf3ee389e4730098e2bc59b46.tar.bz2
gradecoin-868c9714d852761bf3ee389e4730098e2bc59b46.zip
[WIP] Add template support
Diffstat (limited to 'src/handlers.rs')
-rw-r--r--src/handlers.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index a8c9947..b3a6fa8 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -1,5 +1,6 @@
1/// API handlers, the ends of each filter chain
2use aes::Aes128; 1use aes::Aes128;
2/// API handlers, the ends of each filter chain
3use askama::Template;
3use base64; 4use base64;
4use blake2::{Blake2s, Digest}; 5use blake2::{Blake2s, Digest};
5use block_modes::block_padding::Pkcs7; 6use block_modes::block_padding::Pkcs7;
@@ -599,3 +600,19 @@ fn authorize_proposer(jwt_token: String, user_pem: &String) -> Result<TokenData<
599 600
600 Ok(token_payload) 601 Ok(token_payload)
601} 602}
603
604#[derive(Template)]
605#[template(path = "welcome.html")]
606struct WelcomeTemplate<'a> {
607 title: &'a str,
608 body: &'a str,
609}
610
611pub async fn welcome_handler() -> Result<impl warp::Reply, warp::Rejection> {
612 let template = WelcomeTemplate {
613 title: "Welcome",
614 body: "To The Bookstore!",
615 };
616 let res = template.render().unwrap();
617 Ok(warp::reply::html(res))
618}