mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
chore: use local app ctx
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use actix_web::test;
|
||||
use actix_web::{
|
||||
body::{BoxBody, EitherBody},
|
||||
@@ -17,6 +34,15 @@ use crate::api::v1::ROUTES;
|
||||
use crate::errors::*;
|
||||
use crate::ArcData;
|
||||
|
||||
pub fn get_settings() -> Settings {
|
||||
Settings::new().unwrap()
|
||||
}
|
||||
pub async fn get_data() -> ArcData {
|
||||
let settings = get_settings();
|
||||
let data = Data::new(&settings).await;
|
||||
data
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! get_cookie {
|
||||
($resp:expr) => {
|
||||
@@ -50,7 +76,7 @@ macro_rules! get_app {
|
||||
() => {
|
||||
test::init_service(
|
||||
App::new()
|
||||
.wrap(get_identity_service())
|
||||
// .wrap(get_identity_service(&$data.settings))
|
||||
.wrap(actix_middleware::NormalizePath::new(
|
||||
actix_middleware::TrailingSlash::Trim,
|
||||
))
|
||||
@@ -60,7 +86,7 @@ macro_rules! get_app {
|
||||
($data:expr) => {
|
||||
test::init_service(
|
||||
App::new()
|
||||
.wrap(get_identity_service())
|
||||
.wrap(get_identity_service(&$data.settings))
|
||||
.wrap(actix_middleware::NormalizePath::new(
|
||||
actix_middleware::TrailingSlash::Trim,
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user