diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-10-27 01:09:45 +0200 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-10-27 01:09:45 +0200 |
commit | 1dc202f50e35c6ae685b053b7529283af8165a14 (patch) | |
tree | d1ccb9b2b311475727fbe9efcff8f7d55128d607 | |
parent | Indexer: Return json from the /search endpoint (diff) | |
download | OSSE-1dc202f50e35c6ae685b053b7529283af8165a14.tar.gz OSSE-1dc202f50e35c6ae685b053b7529283af8165a14.tar.bz2 OSSE-1dc202f50e35c6ae685b053b7529283af8165a14.zip |
Indexer: Setup permissive CORS
-rw-r--r-- | Cargo.lock | 16 | ||||
-rw-r--r-- | indexer/Cargo.toml | 3 | ||||
-rw-r--r-- | indexer/src/main.rs | 3 |
3 files changed, 21 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock index 8686540..63e25f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,6 +20,21 @@ dependencies = [ ] [[package]] +name = "actix-cors" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "684a6ce1562a5fcca49bc9302896c63547eea78a1e405e837e7416affd8b6eb9" +dependencies = [ + "actix-utils", + "actix-web", + "derive_more", + "futures-util", + "log", + "once_cell", + "smallvec", +] + +[[package]] name = "actix-http" version = "3.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1097,6 +1112,7 @@ dependencies = [ name = "indexer" version = "0.1.0" dependencies = [ + "actix-cors", "actix-web", "html2text", "rand 0.7.3", diff --git a/indexer/Cargo.toml b/indexer/Cargo.toml index 97b8497..32355db 100644 --- a/indexer/Cargo.toml +++ b/indexer/Cargo.toml @@ -6,7 +6,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -actix-web = "*" +actix-web = "4.2.1" +actix-cors = "0.6.3" serde = { version = "1.0", features = ["derive"] } scraper = "0.12.0" html2text = "0.4.3" diff --git a/indexer/src/main.rs b/indexer/src/main.rs index 44dbd1b..4ea81ae 100644 --- a/indexer/src/main.rs +++ b/indexer/src/main.rs @@ -1,3 +1,4 @@ +use actix_cors::Cors; use actix_web::{get, post, web, App, HttpServer, Responder}; use rand::Rng; use serde::{Deserialize, Serialize}; @@ -42,7 +43,9 @@ async fn serve_http_endpoint(address: &str, port: u16) -> std::io::Result<()> { database: Mutex::new(HashMap::new()), }); HttpServer::new(move || { + let cors = Cors::permissive(); App::new() + .wrap(cors) .app_data(shared_state.clone()) .service(search) .service(add_resource) |