|
|
@@ -9,7 +9,7 @@ use tower_http::cors::{Any, CorsLayer}; // 添加Any和CorsLayer的引用
|
|
|
|
|
|
const WEBP: &str =
|
|
|
"https://www.worldflying.cn/tools/webapps/4gplc/"
|
|
|
-// "http://124.222.106.170/plc_ctrl"
|
|
|
+// "http://1 24.222.106.170/plc_ctrl"
|
|
|
;
|
|
|
|
|
|
|
|
|
@@ -49,6 +49,7 @@ struct MqDetail{
|
|
|
struct AppState{
|
|
|
db_lite: sqlite::SqlitePool,
|
|
|
mq_detail: Option<MqDetail>,
|
|
|
+ appsecret: String,
|
|
|
}
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
@@ -90,6 +91,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
// mqtt: String,
|
|
|
ssl_cert: Option<String>,
|
|
|
ssl_key: Option<String>,
|
|
|
+ appsecret: String
|
|
|
}
|
|
|
let conf:Conf =match serde_json::from_reader(match std::fs::File::open(CFGPATH){
|
|
|
Ok(f) => f,
|
|
|
@@ -101,6 +103,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
// mqtt: "/vat/lib/mosquitto.db".to_string(),
|
|
|
ssl_cert: None,
|
|
|
ssl_key: None,
|
|
|
+ appsecret: String::new(),
|
|
|
}).unwrap();
|
|
|
f}
|
|
|
}){
|
|
|
@@ -112,7 +115,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
// mqtt: " /var/lib/mosquitto/data.db".to_string(),
|
|
|
ssl_cert:None,
|
|
|
ssl_key:None,
|
|
|
- ssl:None
|
|
|
+ ssl:None,
|
|
|
+ appsecret: String::new(),
|
|
|
}},
|
|
|
};
|
|
|
|
|
|
@@ -126,7 +130,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
sqlite::init_sqlite_pool("/var/lib/mosquitto/db/acl.db", 10).await,
|
|
|
){
|
|
|
Some(MqDetail { db_mq_user: a, db_mq_latest: b, db_mq_map: c })
|
|
|
- } else{None}
|
|
|
+ } else{None},
|
|
|
+ appsecret: conf.appsecret
|
|
|
};
|
|
|
|
|
|
// let monitor = Counter::new();
|
|
|
@@ -138,11 +143,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
.with_state(appstat.clone())
|
|
|
// 应用完整的CORS配置
|
|
|
.nest("/apilite", axum::Router::new()
|
|
|
- // .nest("/api", axum::Router::new()
|
|
|
- // .route("/wx/auth", get(api::auth::auth))
|
|
|
- .route("/mq", post(api::ability::get_mqtt))
|
|
|
+ .route("/hello", get(async||{"hi"}))
|
|
|
+ // .nest("/api", axum::Router::new()
|
|
|
+ // .route("/wx/auth", get(api::auth::auth))
|
|
|
+ .route("/mq", post(api::ability::get_mqtt))
|
|
|
|
|
|
- .route("/loggin", post(api::user::u_loggin))
|
|
|
+ .route("/loggin", post(api::user::u_loggin))
|
|
|
|
|
|
.route("/device", post(api::device::d_all))
|
|
|
|