diff options
author | Yigit Sever | 2021-04-15 00:32:28 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-15 03:46:30 +0300 |
commit | 2b866db08bd20985a570c4f0f292aaecfe1ea052 (patch) | |
tree | 964b546c50d98b91827a15ed7ed70c94111685d6 /src/handlers.rs | |
parent | bddea30ecb76f0c4805758d3b36aab52f176ff9b (diff) | |
download | gradecoin-2b866db08bd20985a570c4f0f292aaecfe1ea052.tar.gz gradecoin-2b866db08bd20985a570c4f0f292aaecfe1ea052.tar.bz2 gradecoin-2b866db08bd20985a570c4f0f292aaecfe1ea052.zip |
Add template support
We are now serving static HTML alongside Gradecoin REST
Diffstat (limited to 'src/handlers.rs')
-rw-r--r-- | src/handlers.rs | 19 |
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 | ||
2 | use aes::Aes128; | 1 | use aes::Aes128; |
2 | /// API handlers, the ends of each filter chain | ||
3 | use askama::Template; | ||
3 | use base64; | 4 | use base64; |
4 | use blake2::{Blake2s, Digest}; | 5 | use blake2::{Blake2s, Digest}; |
5 | use block_modes::block_padding::Pkcs7; | 6 | use 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")] | ||
606 | struct WelcomeTemplate<'a> { | ||
607 | title: &'a str, | ||
608 | body: &'a str, | ||
609 | } | ||
610 | |||
611 | pub 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 | } | ||