Skip to main content

vertigo_files

Function vertigo_files 

Source
pub fn vertigo_files(cfg: &mut ServiceConfig, mount_config: &MountConfig)
Expand description

Install only the build’s static files, the precompressed ones too if MountConfigBuilder::precompress asked for them - for a back-end that renders the pages by itself, f. ex. with redirects before SSR, and calls vertigo_handler or ServerState on its own.

vertigo_install does this and then mounts the handler. Like it, it needs ServerState initialized before.

use actix_web::{web, App, HttpResponse};
use vertigo_cli::serve::{MountConfigBuilder, ServerState, vertigo_files};

let mount_config = MountConfigBuilder::new("/", "./build").precompress(true).build().unwrap();
ServerState::init(&mount_config).unwrap();

let app = App::new()
    .configure(|cfg| vertigo_files(cfg, &mount_config))
    .default_service(web::to(|| async { HttpResponse::Ok().body("my own page") }));