mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 18:15:39 +00:00
it appears actix-web's scope behaviour has changed in the latest beta
release: Routes 404'd when scope contained trailing slash like so: let scope = "/api/v1/pow/"; web::scope(scope)// So had to rm trailing slash in scope
This commit is contained in:
@@ -15,52 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub enum Methods {
|
||||
/// GET hander
|
||||
Get,
|
||||
/// POST handler
|
||||
Post,
|
||||
/// Protected GET handler
|
||||
ProtectGet,
|
||||
/// Protected POST handler
|
||||
ProtectPost,
|
||||
}
|
||||
|
||||
/// Defines resoures for [Methods]
|
||||
#[macro_export]
|
||||
macro_rules! define_resource {
|
||||
($cfg:expr, $path:expr, Methods::Get, $to:expr) => {
|
||||
$cfg.service(
|
||||
actix_web::web::resource($path)
|
||||
.guard(actix_web::guard::Get())
|
||||
.to($to),
|
||||
);
|
||||
};
|
||||
|
||||
($cfg:expr, $path:expr, Methods::Post, $to:expr) => {
|
||||
$cfg.service(
|
||||
actix_web::Resource::new($path)
|
||||
.guard(actix_web::guard::Post())
|
||||
.to($to),
|
||||
);
|
||||
};
|
||||
|
||||
($cfg:expr, $path:expr, Methods::ProtectPost, $to:expr) => {
|
||||
$cfg.service(
|
||||
actix_web::web::resource($path)
|
||||
.wrap(crate::CheckLogin)
|
||||
.guard(actix_web::guard::Post())
|
||||
.to($to),
|
||||
);
|
||||
};
|
||||
|
||||
($cfg:expr, $path:expr, Methods::ProtectGet, $to:expr) => {
|
||||
$cfg.service(
|
||||
actix_web::web::resource($path)
|
||||
.wrap(crate::CheckLogin)
|
||||
.guard(actix_web::guard::Get())
|
||||
.to($to),
|
||||
);
|
||||
};
|
||||
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
|
||||
crate::api::v1::services(cfg);
|
||||
crate::docs::services(cfg);
|
||||
crate::widget::services(cfg);
|
||||
crate::pages::services(cfg);
|
||||
crate::static_assets::services(cfg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user