neon_arch commited on
Commit
ca13fb7
2 Parent(s): 653d08c 0d8c12e

Merge branch 'improve-logging-based-on-levels-and-opts' of github.com:neon-mmd/websurfx into improve-logging-based-on-levels-and-opts

Browse files
Files changed (3) hide show
  1. Cargo.lock +16 -0
  2. Cargo.toml +1 -0
  3. src/lib.rs +13 -1
Cargo.lock CHANGED
@@ -19,6 +19,21 @@ dependencies = [
19
  "tracing",
20
  ]
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  [[package]]
23
  name = "actix-files"
24
  version = "0.6.2"
@@ -3521,6 +3536,7 @@ dependencies = [
3521
  name = "websurfx"
3522
  version = "0.16.2"
3523
  dependencies = [
 
3524
  "actix-files",
3525
  "actix-web",
3526
  "async-trait",
 
19
  "tracing",
20
  ]
21
 
22
+ [[package]]
23
+ name = "actix-cors"
24
+ version = "0.6.4"
25
+ source = "registry+https://github.com/rust-lang/crates.io-index"
26
+ checksum = "b340e9cfa5b08690aae90fb61beb44e9b06f44fe3d0f93781aaa58cfba86245e"
27
+ dependencies = [
28
+ "actix-utils",
29
+ "actix-web",
30
+ "derive_more",
31
+ "futures-util",
32
+ "log",
33
+ "once_cell",
34
+ "smallvec 1.11.0",
35
+ ]
36
+
37
  [[package]]
38
  name = "actix-files"
39
  version = "0.6.2"
 
3536
  name = "websurfx"
3537
  version = "0.16.2"
3538
  dependencies = [
3539
+ "actix-cors",
3540
  "actix-files",
3541
  "actix-web",
3542
  "async-trait",
Cargo.toml CHANGED
@@ -14,6 +14,7 @@ handlebars = { version = "4.3.6", features = ["dir_source"] }
14
  scraper = {version="*"}
15
  actix-web = {version="4.3.1", features = ["cookies"]}
16
  actix-files = {version="0.6.2"}
 
17
  serde_json = {version="*"}
18
  fake-useragent = {version="*"}
19
  env_logger = {version="0.10.0"}
 
14
  scraper = {version="*"}
15
  actix-web = {version="4.3.1", features = ["cookies"]}
16
  actix-files = {version="0.6.2"}
17
+ actix-cors = {version="0.6.4"}
18
  serde_json = {version="*"}
19
  fake-useragent = {version="*"}
20
  env_logger = {version="0.10.0"}
src/lib.rs CHANGED
@@ -12,8 +12,9 @@ use std::net::TcpListener;
12
 
13
  use crate::server::routes;
14
 
 
15
  use actix_files as fs;
16
- use actix_web::{dev::Server, middleware::Logger, web, App, HttpServer};
17
  use config::parser::Config;
18
  use handlebars::Handlebars;
19
  use handler::public_paths::public_path;
@@ -52,9 +53,20 @@ pub fn run(listener: TcpListener, config: Config) -> std::io::Result<Server> {
52
  let cloned_config_threads_opt: u8 = config.threads;
53
 
54
  let server = HttpServer::new(move || {
 
 
 
 
 
 
 
 
 
 
55
  App::new()
56
  .app_data(handlebars_ref.clone())
57
  .app_data(web::Data::new(config.clone()))
 
58
  .wrap(Logger::default()) // added logging middleware for logging.
59
  // Serve images and static files (css and js files).
60
  .service(
 
12
 
13
  use crate::server::routes;
14
 
15
+ use actix_cors::Cors;
16
  use actix_files as fs;
17
+ use actix_web::{dev::Server, http::header, middleware::Logger, web, App, HttpServer};
18
  use config::parser::Config;
19
  use handlebars::Handlebars;
20
  use handler::public_paths::public_path;
 
53
  let cloned_config_threads_opt: u8 = config.threads;
54
 
55
  let server = HttpServer::new(move || {
56
+ let cors: Cors = Cors::default()
57
+ .allow_any_origin()
58
+ .allowed_methods(vec!["GET"])
59
+ .allowed_headers(vec![
60
+ header::ORIGIN,
61
+ header::CONTENT_TYPE,
62
+ header::REFERER,
63
+ header::COOKIE,
64
+ ]);
65
+
66
  App::new()
67
  .app_data(handlebars_ref.clone())
68
  .app_data(web::Data::new(config.clone()))
69
+ .wrap(cors)
70
  .wrap(Logger::default()) // added logging middleware for logging.
71
  // Serve images and static files (css and js files).
72
  .service(