mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 18:15:39 +00:00
using custom version of actix-codegen and cors for pow routes
This commit is contained in:
@@ -25,10 +25,6 @@ pub enum Methods {
|
||||
ProtectGet,
|
||||
/// Protected POST handler
|
||||
ProtectPost,
|
||||
/// CORS allow all orgin GET handler
|
||||
CorsAllowAllGet,
|
||||
/// CORS allow all orgin PST handler
|
||||
CorsAllowAllPost,
|
||||
}
|
||||
|
||||
/// Defines resoures for [Methods]
|
||||
@@ -67,29 +63,4 @@ macro_rules! define_resource {
|
||||
.to($to),
|
||||
);
|
||||
};
|
||||
|
||||
($cfg:expr, $path:expr, Methods::CorsAllowAllGet, $cors:expr, $to:expr) => {
|
||||
$cfg.service(
|
||||
actix_web::web::resource($path)
|
||||
.wrap($cors)
|
||||
.guard(actix_web::guard::Get())
|
||||
.to($to),
|
||||
);
|
||||
};
|
||||
|
||||
($cfg:expr, $path:expr, Methods::CorsAllowAllPost, $to:expr) => {
|
||||
let cors = Cors::default()
|
||||
.allow_any_origin()
|
||||
.allowed_methods(vec!["POST"])
|
||||
.allow_any_header()
|
||||
.max_age(0)
|
||||
.send_wildcard();
|
||||
|
||||
$cfg.service(
|
||||
actix_web::web::resource($path)
|
||||
.wrap(cors)
|
||||
.guard(actix_web::guard::Post())
|
||||
.to($to),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user