2022-03-05 12:47:11 +01:00
|
|
|
use actix_files::{Files, NamedFile};
|
|
|
|
use actix_web::{web, Result};
|
2021-05-02 12:32:03 +02:00
|
|
|
|
2022-07-19 21:55:05 +02:00
|
|
|
use crate::config;
|
|
|
|
|
2021-05-02 12:32:03 +02:00
|
|
|
pub fn init(cfg: &mut web::ServiceConfig) {
|
2022-03-12 14:07:33 +01:00
|
|
|
cfg.service(
|
2022-07-19 21:55:05 +02:00
|
|
|
Files::new("/", config::FRONTEND_PATH.to_string())
|
2022-03-12 14:07:33 +01:00
|
|
|
.index_file("index.html")
|
|
|
|
.use_etag(true),
|
|
|
|
);
|
2021-05-02 12:32:03 +02:00
|
|
|
}
|
2022-03-05 12:47:11 +01:00
|
|
|
|
|
|
|
pub async fn index() -> Result<NamedFile> {
|
2022-07-19 21:55:05 +02:00
|
|
|
let index = format!("{}{}", config::FRONTEND_PATH.to_string(), "/index.html");
|
|
|
|
Ok(NamedFile::open(index)?)
|
2022-03-05 12:47:11 +01:00
|
|
|
}
|