add web3 route
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-04-14 12:25:20 +02:00
parent d2b520d9b6
commit e5b5020d58
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 21 additions and 1 deletions

View file

@ -2,7 +2,7 @@ use actix_files::Files;
use actix_web::{middleware::DefaultHeaders, web, App, HttpServer};
use std::io::Result;
use crate::routes::{agreements, blog, contrib, index, networks, not_found, portfolio};
use crate::routes::{agreements, blog, contrib, index, networks, not_found, portfolio, web3};
mod config;
mod template;
@ -40,6 +40,7 @@ async fn main() -> Result<()> {
.service(contrib::page)
.service(blog::index)
.service(blog::page)
.service(web3::page)
.service(Files::new("/", config.static_location.clone()))
.default_service(web::to(not_found::page))
})

View file

@ -5,3 +5,4 @@ pub mod index;
pub mod networks;
pub mod not_found;
pub mod portfolio;
pub mod web3;

18
src/routes/web3.rs Normal file
View file

@ -0,0 +1,18 @@
use actix_web::{get, web, HttpResponse, Responder};
use cached::proc_macro::once;
use ramhorns::Content;
use crate::{config::Config, template::read_md};
#[get("/web3")]
pub async fn page(config: web::Data<Config>) -> impl Responder {
HttpResponse::Ok().body(get_page(config.get_ref().clone()))
}
#[derive(Content)]
struct Web3Template {}
#[once(time = 60)]
pub fn get_page(_config: Config) -> String {
read_md("[WEB3](https://web3isgoinggreat.com/)").content
}