add Shield to remove warning

This commit is contained in:
fabolous005 2024-12-03 09:06:02 +01:00
parent 717e92b506
commit e4172bd159

View File

@ -1,6 +1,6 @@
#[macro_use] extern crate rocket;
use rocket::form::Form;
use rocket::{form::Form, shield::{Hsts, NoSniff}, time::Duration};
use rocket_dyn_templates::{Template, context};
use rocket::fs::FileServer;
use rocket::shield::Shield;
@ -51,10 +51,13 @@ fn index(ip: IpAddr) -> Template {
#[launch]
fn rocket() -> _ {
let shield = Shield::new()
.enable(Hsts::Enable(Duration::MAX))
.enable(NoSniff::Enable);
rocket::build()
.mount("/", routes![index, login])
.mount("/static", FileServer::from("static")) // Serves files in the `static` directory
.attach(Shield::new())
.attach(shield)
.attach(Template::fairing())
}