Added middleware for mimetype

This commit is contained in:
2025-10-06 16:46:06 +02:00
parent 4eaf54dd8f
commit a457efb97e
2 changed files with 76 additions and 3 deletions

View File

@@ -1,15 +1,25 @@
mod html;
mod pages;
mod middleware;
use actix_web::{App, HttpServer};
use actix_web::{web, App, HttpServer};
use pages::{files::file, index};
use pages::{files::file, index, projects::{projects, project}};
use middleware::MimeType;
#[actix_web::main]
async fn main() {
let bind_address = "0.0.0.0:8080";
if let Ok(server) =
HttpServer::new(|| App::new().service(index).service(file)).bind(bind_address)
HttpServer::new(|| App::new()
.service(file)
.service(web::scope("")
.wrap(MimeType::new("text/html".to_string()))
.service(index)
.service(projects)
.service(project)
)
).bind(bind_address)
{
match server.run().await {
Ok(_) => {}