Merge branch 'rolling' into patch-csrf-security-with-cors
This commit is contained in:
commit
9d3a8e065a
5 changed files with 63 additions and 16 deletions
|
@ -35,7 +35,7 @@ use handler::public_paths::public_path;
|
|||
/// use std::net::TcpListener;
|
||||
/// use websurfx::{config::parser::Config, run};
|
||||
///
|
||||
/// let config = Config::parse().unwrap();
|
||||
/// let config = Config::parse(true).unwrap();
|
||||
/// let listener = TcpListener::bind("127.0.0.1:8080").expect("Failed to bind address");
|
||||
/// let server = run(listener,config).expect("Failed to start server");
|
||||
/// ```
|
||||
|
@ -50,6 +50,8 @@ pub fn run(listener: TcpListener, config: Config) -> std::io::Result<Server> {
|
|||
|
||||
let handlebars_ref: web::Data<Handlebars> = web::Data::new(handlebars);
|
||||
|
||||
let cloned_config_threads_opt: u8 = config.threads;
|
||||
|
||||
let server = HttpServer::new(move || {
|
||||
let cors: Cors = Cors::default()
|
||||
.allow_any_origin()
|
||||
|
@ -82,6 +84,7 @@ pub fn run(listener: TcpListener, config: Config) -> std::io::Result<Server> {
|
|||
.service(routes::settings) // settings page
|
||||
.default_service(web::route().to(routes::not_found)) // error page
|
||||
})
|
||||
.workers(cloned_config_threads_opt as usize)
|
||||
// Start server on 127.0.0.1 with the user provided port number. for example 127.0.0.1:8080.
|
||||
.listen(listener)?
|
||||
.run();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue