Serve static files
This commit is contained in:
@ -7,6 +7,25 @@ use actix_session::Session;
|
||||
use actix_web::{web, HttpResponse};
|
||||
use light_openid::primitives::OpenIDConfig;
|
||||
|
||||
/// Static assets
|
||||
#[derive(rust_embed::Embed)]
|
||||
#[folder = "assets/"]
|
||||
struct Assets;
|
||||
|
||||
/// Serve static file
|
||||
pub async fn static_file(path: web::Path<String>) -> HttpResult {
|
||||
match Assets::get(path.as_ref()) {
|
||||
Some(content) => Ok(HttpResponse::Ok()
|
||||
.content_type(
|
||||
mime_guess::from_path(path.as_str())
|
||||
.first_or_octet_stream()
|
||||
.as_ref(),
|
||||
)
|
||||
.body(content.data.into_owned())),
|
||||
None => Ok(HttpResponse::NotFound().body("404 Not Found")),
|
||||
}
|
||||
}
|
||||
|
||||
/// Main route
|
||||
pub async fn home(session: Session) -> HttpResult {
|
||||
// Get user information, requesting authentication if information is missing
|
||||
|
Reference in New Issue
Block a user