Support front end deployment
This commit is contained in:
52
did_router/Cargo.lock
generated
52
did_router/Cargo.lock
generated
@@ -34,6 +34,29 @@ dependencies = [
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "actix-files"
|
||||
version = "0.6.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df8c4f30e3272d7c345f88ae0aac3848507ef5ba871f9cc2a41c8085a0f0523b"
|
||||
dependencies = [
|
||||
"actix-http",
|
||||
"actix-service",
|
||||
"actix-utils",
|
||||
"actix-web",
|
||||
"bitflags",
|
||||
"bytes",
|
||||
"derive_more 2.1.1",
|
||||
"futures-core",
|
||||
"http-range",
|
||||
"log",
|
||||
"mime",
|
||||
"mime_guess",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"v_htmlescape",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "actix-http"
|
||||
version = "3.12.0"
|
||||
@@ -523,6 +546,7 @@ name = "did_router"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"actix-cors",
|
||||
"actix-files",
|
||||
"actix-multipart",
|
||||
"actix-web",
|
||||
"diesel",
|
||||
@@ -828,6 +852,12 @@ dependencies = [
|
||||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-range"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573"
|
||||
|
||||
[[package]]
|
||||
name = "httparse"
|
||||
version = "1.10.1"
|
||||
@@ -1048,6 +1078,16 @@ version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||
|
||||
[[package]]
|
||||
name = "mime_guess"
|
||||
version = "2.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
|
||||
dependencies = [
|
||||
"mime",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.9"
|
||||
@@ -1651,6 +1691,12 @@ version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb"
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.24"
|
||||
@@ -1687,6 +1733,12 @@ version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
|
||||
|
||||
[[package]]
|
||||
name = "v_htmlescape"
|
||||
version = "0.15.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
|
||||
@@ -16,3 +16,4 @@ diesel-derive-enum = { version = "3.0.0-beta.1", features = ["postgres"] }
|
||||
strum = "0.24"
|
||||
strum_macros = "0.24"
|
||||
actix-cors = "0.7.1"
|
||||
actix-files = "0.6.10"
|
||||
|
||||
@@ -8,9 +8,10 @@ use actix_web::{web, App,
|
||||
HttpResponse,
|
||||
HttpServer,
|
||||
http::header::ContentType,
|
||||
Responder,
|
||||
Responder, Result
|
||||
};
|
||||
use actix_cors::Cors;
|
||||
use actix_files::{Files, NamedFile};
|
||||
use serde::Deserialize;
|
||||
use database as db;
|
||||
use database::DidTargetType;
|
||||
@@ -47,7 +48,6 @@ async fn route_did(request: web::Form<RouteRequest>) -> impl Responder {
|
||||
async fn did_post(d: web::Json<JsonDid>) -> impl Responder {
|
||||
let did = d.deref();
|
||||
|
||||
println!("{:?}", did);
|
||||
db::add_did(&did.did_number, &did.target_type, &did.target, did.active ,&did.trunk).unwrap();
|
||||
HttpResponse::Ok().body("DID added.")
|
||||
}
|
||||
@@ -107,14 +107,19 @@ fn api_config(cfg: &mut web::ServiceConfig) {
|
||||
);
|
||||
}
|
||||
|
||||
async fn index() -> Result<NamedFile> {
|
||||
Ok(NamedFile::open("/var/www/did_router/index.html")?)
|
||||
}
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| {
|
||||
let cors = Cors::permissive();
|
||||
App::new()
|
||||
.wrap(cors)
|
||||
.service(Files::new("/admin", "/var/www/did_router/").index_file("index.html"))
|
||||
.service(
|
||||
web::scope("/api").configure(api_config))
|
||||
.default_service(web::route().to(index))
|
||||
})
|
||||
.bind(("0.0.0.0", 3000))?
|
||||
.run()
|
||||
|
||||
Reference in New Issue
Block a user