-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.rs
45 lines (40 loc) · 1.43 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Dyn conn service
//!
//! test case
mod mongo;
mod sql;
mod util;
use actix_web::{web, App, HttpServer};
use fabrix::DynConn;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let dc_sql: util::DcSql = DynConn::new();
let data_sql = web::Data::new(dc_sql);
let dc_mongo: util::DcMongo = DynConn::new();
let data_mongo = web::Data::new(dc_mongo);
HttpServer::new(move || {
App::new()
.service(
web::scope("/sql")
.app_data(data_sql.clone())
.route("/", web::get().to(sql::index))
.route("/add", web::post().to(sql::add))
.route("/remove", web::delete().to(sql::remove))
.route("/connect", web::get().to(sql::connect))
.route("/disconnect", web::delete().to(sql::disconnect))
.route("/check", web::get().to(sql::check)),
)
.service(
web::scope("/mongo")
.app_data(data_mongo.clone())
.route("/", web::get().to(mongo::index))
.route("/add", web::post().to(mongo::add))
.route("/remove", web::delete().to(mongo::remove))
.route("/connect", web::get().to(mongo::connect))
.route("/check", web::get().to(mongo::check)),
)
})
.bind(("127.0.0.1", 8060))?
.run()
.await
}