Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	anubis-eval/.env.template
#	enki-problems/.env.template
#	enki-problems/src/EnkiProblems.Application/Problems/ProblemAppService.cs
#	enki-problems/src/EnkiProblems.HttpApi.Host/EnkiProblemsHttpApiHostModule.cs
#	odin-gateway/envoy.yaml
#	quetzalcoatl-auth/Api/Features/Auth/Login/Endpoint.cs
#	quetzalcoatl-auth/Api/Features/Auth/Register/Endpoint.cs
#	quetzalcoatl-auth/Api/Usings.cs
#	quetzalcoatl-auth/Infrastructure/ApplicationDbContext.cs
  • Loading branch information
WarriorsSami committed May 11, 2024
2 parents 7b60949 + a0e6f75 commit f216ea5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
43 changes: 43 additions & 0 deletions anubis-eval/src/api/cors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use crate::config::di::CONFIG;
use rocket::fairing::Fairing;

pub struct Cors;

#[rocket::async_trait]
impl Fairing for Cors {
fn info(&self) -> rocket::fairing::Info {
rocket::fairing::Info {
name: "Add CORS headers to responses",
kind: rocket::fairing::Kind::Response,
}
}

async fn on_response<'r>(
&self,
_request: &'r rocket::Request<'_>,
response: &mut rocket::Response<'r>,
) {
let allowed_origins = CONFIG
.allowed_origins
.split(';')
.map(String::from)
.collect::<Vec<String>>();

response.set_header(rocket::http::Header::new(
"Access-Control-Allow-Origin",
allowed_origins.join(","),
));
response.set_header(rocket::http::Header::new(
"Access-Control-Allow-Methods",
"POST, GET, OPTIONS",
));
response.set_header(rocket::http::Header::new(
"Access-Control-Allow-Headers",
"*",
));
response.set_header(rocket::http::Header::new(
"Access-Control-Allow-Credentials",
"true",
));
}
}
1 change: 1 addition & 0 deletions anubis-eval/src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod catchers;
pub mod cors;
pub mod create_submission_endpoint;
pub mod evaluate_submission_job;
pub mod get_highest_score_submissions;
Expand Down
1 change: 1 addition & 0 deletions anubis-eval/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rocket::fairing::AdHoc;
use rocket::log::private::info;
use rocket::{catchers, error, launch, routes};
use tokio_cron_scheduler::{Job, JobScheduler};
use crate::api::cors::Cors;

mod api;
mod application;
Expand Down

0 comments on commit f216ea5

Please sign in to comment.