diff --git a/Cargo.lock b/Cargo.lock index 9e0edb4..0c4849a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1238,7 +1238,7 @@ checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "salvo-cli" -version = "0.1.45" +version = "0.1.47" dependencies = [ "ansi_term", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 00f1cea..4f42444 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "salvo-cli" -version = "0.1.46" +version = "0.1.47" edition = "2021" authors = ["Fankai Liu liufankai137@outlook.com","mrxiaozhuox mrxzx.info@gmail.com"] keywords = ["salvo", "cli","template"] diff --git a/src/template/src/main_template.hbs b/src/template/src/main_template.hbs index e3529d7..66a7dfa 100644 --- a/src/template/src/main_template.hbs +++ b/src/template/src/main_template.hbs @@ -9,7 +9,7 @@ use crate::db::init_db_conn; {{/if}} use tokio::signal; use tracing::info; -use crate::middleware::handle_404::handle_404; +use crate::middleware::{handle_404::handle_404,cors::cors_middleware}; use crate::routers::router; use config::{CERT_KEY, CFG}; use salvo::server::ServerHandle; @@ -69,10 +69,10 @@ async fn main() { {{/if}} let router = router(); let service: Service = router.into(); - let service = service.catcher(Catcher::default().hoop(handle_404)); + let service = service.catcher(Catcher::default().hoop(handle_404));//.hoop(_cors_handler).hoop(handle_404)); println!("🌪️ {} {{is_starting}} ", &CFG.server.name); println!("🔄 {{listen_on}} {}", &CFG.server.address); - + let _cors_handler = cors_middleware(); match CFG.server.ssl { true => { println!( diff --git a/src/template/src/routers/mod.hbs b/src/template/src/routers/mod.hbs index 08b1772..22b104a 100644 --- a/src/template/src/routers/mod.hbs +++ b/src/template/src/routers/mod.hbs @@ -1,6 +1,6 @@ {{#if need_db_conn}} {{#if is_web_site}} -use crate::middleware::{cors::cors_middleware, jwt::jwt_middleware}; +use crate::middleware::jwt::jwt_middleware; use salvo::{ prelude::{CatchPanic, Logger, OpenApi, SwaggerUi}, Router, @@ -23,8 +23,6 @@ pub fn router() -> Router { Router::with_path("/api/login").post(post_login), ]; - let _cors_handler = cors_middleware(); - let mut need_auth_routers = vec![ Router::with_path("users") .get(user_list_page), @@ -39,7 +37,6 @@ pub fn router() -> Router { let static_routers = static_routers::create_static_routers(); no_auth_routers.extend(static_routers); let router = Router::new() - //.hoop(_cors_handler) .hoop(Logger::new()) .hoop(CatchPanic::new()) .get(hello)