chore: lint, use actix_web_codegen_const_routes and serde all routes
This commit is contained in:
parent
17307074c3
commit
73cfe1b95d
15 changed files with 56 additions and 38 deletions
|
@ -22,7 +22,7 @@ use super::auth::runners::Password;
|
||||||
use crate::errors::*;
|
use crate::errors::*;
|
||||||
use crate::AppData;
|
use crate::AppData;
|
||||||
|
|
||||||
#[my_codegen::post(
|
#[actix_web_codegen_const_routes::post(
|
||||||
path = "crate::V1_API_ROUTES.admin.account.delete",
|
path = "crate::V1_API_ROUTES.admin.account.delete",
|
||||||
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
||||||
)]
|
)]
|
||||||
|
|
|
@ -29,7 +29,9 @@ pub struct Email {
|
||||||
pub email: String,
|
pub email: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[my_codegen::post(path = "crate::V1_API_ROUTES.admin.account.email_exists")]
|
#[actix_web_codegen_const_routes::post(
|
||||||
|
path = "crate::V1_API_ROUTES.admin.account.email_exists"
|
||||||
|
)]
|
||||||
pub async fn email_exists(
|
pub async fn email_exists(
|
||||||
payload: web::Json<AccountCheckPayload>,
|
payload: web::Json<AccountCheckPayload>,
|
||||||
data: AppData,
|
data: AppData,
|
||||||
|
@ -53,7 +55,7 @@ pub async fn email_exists(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// update email
|
/// update email
|
||||||
#[my_codegen::post(
|
#[actix_web_codegen_const_routes::post(
|
||||||
path = "crate::V1_API_ROUTES.admin.account.update_email",
|
path = "crate::V1_API_ROUTES.admin.account.update_email",
|
||||||
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
||||||
)]
|
)]
|
||||||
|
|
|
@ -28,7 +28,9 @@ pub mod username;
|
||||||
pub use super::auth;
|
pub use super::auth;
|
||||||
|
|
||||||
pub mod routes {
|
pub mod routes {
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
|
||||||
pub struct Account {
|
pub struct Account {
|
||||||
pub delete: &'static str,
|
pub delete: &'static str,
|
||||||
pub email_exists: &'static str,
|
pub email_exists: &'static str,
|
||||||
|
|
|
@ -68,7 +68,7 @@ async fn update_password_runner(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[my_codegen::post(
|
#[actix_web_codegen_const_routes::post(
|
||||||
path = "crate::V1_API_ROUTES.admin.account.update_password",
|
path = "crate::V1_API_ROUTES.admin.account.update_password",
|
||||||
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
||||||
)]
|
)]
|
||||||
|
@ -118,7 +118,6 @@ mod tests {
|
||||||
use actix_web::test;
|
use actix_web::test;
|
||||||
|
|
||||||
use crate::api::v1::ROUTES;
|
use crate::api::v1::ROUTES;
|
||||||
use crate::data::Data;
|
|
||||||
use crate::tests::*;
|
use crate::tests::*;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
|
@ -128,7 +127,7 @@ mod tests {
|
||||||
const EMAIL: &str = "updatepassuser@a.com";
|
const EMAIL: &str = "updatepassuser@a.com";
|
||||||
|
|
||||||
{
|
{
|
||||||
let data = Data::new().await;
|
let data = get_test_data().await;
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub struct Secret {
|
||||||
pub secret: String,
|
pub secret: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[my_codegen::get(
|
#[actix_web_codegen_const_routes::get(
|
||||||
path = "crate::V1_API_ROUTES.admin.account.get_secret",
|
path = "crate::V1_API_ROUTES.admin.account.get_secret",
|
||||||
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
||||||
)]
|
)]
|
||||||
|
@ -47,7 +47,7 @@ async fn get_secret(id: Identity, data: AppData) -> ServiceResult<impl Responder
|
||||||
Ok(HttpResponse::Ok().json(secret))
|
Ok(HttpResponse::Ok().json(secret))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[my_codegen::post(
|
#[actix_web_codegen_const_routes::post(
|
||||||
path = "crate::V1_API_ROUTES.admin.account.update_secret",
|
path = "crate::V1_API_ROUTES.admin.account.update_secret",
|
||||||
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
||||||
)]
|
)]
|
||||||
|
|
|
@ -23,7 +23,6 @@ use super::username::Username;
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::api::v1::admin::auth::runners::Password;
|
use crate::api::v1::admin::auth::runners::Password;
|
||||||
use crate::api::v1::ROUTES;
|
use crate::api::v1::ROUTES;
|
||||||
use crate::data::Data;
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
use crate::errors::*;
|
use crate::errors::*;
|
||||||
|
@ -36,7 +35,7 @@ async fn uname_email_exists_works() {
|
||||||
const EMAIL: &str = "testuserexists@a.com2";
|
const EMAIL: &str = "testuserexists@a.com2";
|
||||||
|
|
||||||
{
|
{
|
||||||
let data = Data::new().await;
|
let data = get_test_data().await;
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +125,7 @@ async fn email_udpate_password_validation_del_userworks() {
|
||||||
const EMAIL2: &str = "eupdauser@a.com";
|
const EMAIL2: &str = "eupdauser@a.com";
|
||||||
|
|
||||||
{
|
{
|
||||||
let data = Data::new().await;
|
let data = get_test_data().await;
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
delete_user(NAME2, &data).await;
|
delete_user(NAME2, &data).await;
|
||||||
}
|
}
|
||||||
|
@ -209,7 +208,7 @@ async fn username_update_works() {
|
||||||
const NAME_CHANGE: &str = "terstusrtdsxx";
|
const NAME_CHANGE: &str = "terstusrtdsxx";
|
||||||
|
|
||||||
{
|
{
|
||||||
let data = Data::new().await;
|
let data = get_test_data().await;
|
||||||
|
|
||||||
futures::join!(
|
futures::join!(
|
||||||
delete_user(NAME, &data),
|
delete_user(NAME, &data),
|
||||||
|
|
|
@ -24,7 +24,9 @@ use super::{AccountCheckPayload, AccountCheckResp};
|
||||||
use crate::errors::*;
|
use crate::errors::*;
|
||||||
use crate::AppData;
|
use crate::AppData;
|
||||||
|
|
||||||
#[my_codegen::post(path = "crate::V1_API_ROUTES.admin.account.username_exists")]
|
#[actix_web_codegen_const_routes::post(
|
||||||
|
path = "crate::V1_API_ROUTES.admin.account.username_exists"
|
||||||
|
)]
|
||||||
async fn username_exists(
|
async fn username_exists(
|
||||||
payload: web::Json<AccountCheckPayload>,
|
payload: web::Json<AccountCheckPayload>,
|
||||||
data: AppData,
|
data: AppData,
|
||||||
|
@ -65,7 +67,7 @@ pub struct Username {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// update username
|
/// update username
|
||||||
#[my_codegen::post(
|
#[actix_web_codegen_const_routes::post(
|
||||||
path = "crate::V1_API_ROUTES.admin.account.update_username",
|
path = "crate::V1_API_ROUTES.admin.account.update_username",
|
||||||
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
||||||
)]
|
)]
|
||||||
|
|
|
@ -26,7 +26,9 @@ use crate::AppData;
|
||||||
|
|
||||||
pub mod routes {
|
pub mod routes {
|
||||||
use actix_auth_middleware::GetLoginRoute;
|
use actix_auth_middleware::GetLoginRoute;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
|
||||||
pub struct Auth {
|
pub struct Auth {
|
||||||
pub logout: &'static str,
|
pub logout: &'static str,
|
||||||
pub login: &'static str,
|
pub login: &'static str,
|
||||||
|
@ -153,7 +155,7 @@ pub mod runners {
|
||||||
payload: &Register,
|
payload: &Register,
|
||||||
data: &AppData,
|
data: &AppData,
|
||||||
) -> ServiceResult<()> {
|
) -> ServiceResult<()> {
|
||||||
if !crate::SETTINGS.allow_registration {
|
if !data.settings.allow_registration {
|
||||||
return Err(ServiceError::ClosedForRegistration);
|
return Err(ServiceError::ClosedForRegistration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +224,9 @@ pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
cfg.service(login);
|
cfg.service(login);
|
||||||
cfg.service(signout);
|
cfg.service(signout);
|
||||||
}
|
}
|
||||||
#[my_codegen::post(path = "crate::V1_API_ROUTES.admin.auth.register")]
|
#[actix_web_codegen_const_routes::post(
|
||||||
|
path = "crate::V1_API_ROUTES.admin.auth.register"
|
||||||
|
)]
|
||||||
async fn register(
|
async fn register(
|
||||||
payload: web::Json<runners::Register>,
|
payload: web::Json<runners::Register>,
|
||||||
data: AppData,
|
data: AppData,
|
||||||
|
@ -231,7 +235,7 @@ async fn register(
|
||||||
Ok(HttpResponse::Ok())
|
Ok(HttpResponse::Ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[my_codegen::post(path = "crate::V1_API_ROUTES.admin.auth.login")]
|
#[actix_web_codegen_const_routes::post(path = "crate::V1_API_ROUTES.admin.auth.login")]
|
||||||
async fn login(
|
async fn login(
|
||||||
id: Identity,
|
id: Identity,
|
||||||
payload: web::Json<runners::Login>,
|
payload: web::Json<runners::Login>,
|
||||||
|
@ -250,7 +254,7 @@ async fn login(
|
||||||
Ok(HttpResponse::Ok().into())
|
Ok(HttpResponse::Ok().into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[my_codegen::get(
|
#[actix_web_codegen_const_routes::get(
|
||||||
path = "crate::V1_API_ROUTES.admin.auth.logout",
|
path = "crate::V1_API_ROUTES.admin.auth.logout",
|
||||||
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
wrap = "crate::api::v1::admin::get_admin_check_login()"
|
||||||
)]
|
)]
|
||||||
|
|
|
@ -27,6 +27,9 @@ use crate::errors::*;
|
||||||
use crate::AppData;
|
use crate::AppData;
|
||||||
|
|
||||||
pub mod routes {
|
pub mod routes {
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
|
||||||
pub struct Campaign {
|
pub struct Campaign {
|
||||||
pub add: &'static str,
|
pub add: &'static str,
|
||||||
pub delete: &'static str,
|
pub delete: &'static str,
|
||||||
|
@ -250,7 +253,7 @@ pub mod runners {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[my_codegen::post(
|
#[actix_web_codegen_const_routes::post(
|
||||||
path = "crate::V1_API_ROUTES.admin.campaign.delete",
|
path = "crate::V1_API_ROUTES.admin.campaign.delete",
|
||||||
wrap = "get_admin_check_login()"
|
wrap = "get_admin_check_login()"
|
||||||
)]
|
)]
|
||||||
|
@ -279,7 +282,7 @@ pub async fn delete(
|
||||||
// pub feedbacks: Vec<Feedback>,
|
// pub feedbacks: Vec<Feedback>,
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//#[my_codegen::post(
|
//#[actix_web_codegen_const_routes::post(
|
||||||
// path = "crate::V1_API_ROUTES.campaign.get_feedback",
|
// path = "crate::V1_API_ROUTES.campaign.get_feedback",
|
||||||
// wrap = "crate::CheckLogin"
|
// wrap = "crate::CheckLogin"
|
||||||
//)]
|
//)]
|
||||||
|
@ -300,7 +303,7 @@ pub struct ListCampaignResp {
|
||||||
pub uuid: String,
|
pub uuid: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[my_codegen::post(
|
#[actix_web_codegen_const_routes::post(
|
||||||
path = "crate::V1_API_ROUTES.admin.campaign.list",
|
path = "crate::V1_API_ROUTES.admin.campaign.list",
|
||||||
wrap = "get_admin_check_login()"
|
wrap = "get_admin_check_login()"
|
||||||
)]
|
)]
|
||||||
|
@ -332,7 +335,7 @@ pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
//cfg.service(get_feedback);
|
//cfg.service(get_feedback);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[my_codegen::post(path = "crate::V1_API_ROUTES.admin.campaign.add")]
|
#[actix_web_codegen_const_routes::post(path = "crate::V1_API_ROUTES.admin.campaign.add")]
|
||||||
async fn add(
|
async fn add(
|
||||||
payload: web::Json<AddCapmaign>,
|
payload: web::Json<AddCapmaign>,
|
||||||
data: AppData,
|
data: AppData,
|
||||||
|
@ -350,7 +353,6 @@ async fn add(
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::api::v1::bench::Submission;
|
use crate::api::v1::bench::Submission;
|
||||||
use crate::data::Data;
|
|
||||||
use crate::errors::*;
|
use crate::errors::*;
|
||||||
use crate::tests::*;
|
use crate::tests::*;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
@ -360,7 +362,7 @@ mod tests {
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_bench_register_works() {
|
async fn test_bench_register_works() {
|
||||||
let data = Data::new().await;
|
let data = get_test_data().await;
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
let signin_resp = test::call_service(
|
let signin_resp = test::call_service(
|
||||||
&app,
|
&app,
|
||||||
|
@ -400,7 +402,7 @@ mod tests {
|
||||||
const THREADS: i32 = 4;
|
const THREADS: i32 = 4;
|
||||||
|
|
||||||
{
|
{
|
||||||
let data = Data::new().await;
|
let data = get_test_data().await;
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ pub mod campaigns;
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
pub use super::{get_random, get_uuid, RedirectQuery};
|
pub use super::{get_random, get_uuid, RedirectQuery};
|
||||||
use crate::api::v1::bench::SURVEY_USER_ID;
|
|
||||||
|
|
||||||
pub fn services(cfg: &mut ServiceConfig) {
|
pub fn services(cfg: &mut ServiceConfig) {
|
||||||
auth::services(cfg);
|
auth::services(cfg);
|
||||||
|
@ -40,7 +39,9 @@ pub mod routes {
|
||||||
use super::account::routes::Account;
|
use super::account::routes::Account;
|
||||||
use super::auth::routes::Auth;
|
use super::auth::routes::Auth;
|
||||||
use super::campaigns::routes::Campaign;
|
use super::campaigns::routes::Campaign;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
|
||||||
pub struct Admin {
|
pub struct Admin {
|
||||||
pub auth: Auth,
|
pub auth: Auth,
|
||||||
pub account: Account,
|
pub account: Account,
|
||||||
|
|
|
@ -20,7 +20,6 @@ use actix_web::test;
|
||||||
|
|
||||||
use crate::api::v1::admin::auth::runners::{Login, Register};
|
use crate::api::v1::admin::auth::runners::{Login, Register};
|
||||||
use crate::api::v1::ROUTES;
|
use crate::api::v1::ROUTES;
|
||||||
use crate::data::Data;
|
|
||||||
use crate::errors::*;
|
use crate::errors::*;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@ use crate::tests::*;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn auth_works() {
|
async fn auth_works() {
|
||||||
let data = Data::new().await;
|
let data = get_test_data().await;
|
||||||
const NAME: &str = "testuser";
|
const NAME: &str = "testuser";
|
||||||
const PASSWORD: &str = "longpassword";
|
const PASSWORD: &str = "longpassword";
|
||||||
const EMAIL: &str = "testuser1@a.com";
|
const EMAIL: &str = "testuser1@a.com";
|
||||||
|
@ -146,7 +145,7 @@ async fn serverside_password_validation_works() {
|
||||||
const NAME: &str = "testuser542";
|
const NAME: &str = "testuser542";
|
||||||
const PASSWORD: &str = "longpassword2";
|
const PASSWORD: &str = "longpassword2";
|
||||||
|
|
||||||
let data = Data::new().await;
|
let data = get_test_data().await;
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
|
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
use actix_web::http::StatusCode;
|
use actix_web::http::StatusCode;
|
||||||
use actix_web::test;
|
use actix_web::test;
|
||||||
|
|
||||||
use crate::data::Data;
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
use crate::tests::*;
|
use crate::tests::*;
|
||||||
|
@ -32,7 +31,7 @@ async fn protected_routes_work() {
|
||||||
let get_protected_urls = [V1_API_ROUTES.admin.auth.logout];
|
let get_protected_urls = [V1_API_ROUTES.admin.auth.logout];
|
||||||
|
|
||||||
{
|
{
|
||||||
let data = Data::new().await;
|
let data = get_test_data().await;
|
||||||
delete_user(NAME, &data).await;
|
delete_user(NAME, &data).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,11 @@ use crate::AppData;
|
||||||
pub const SURVEY_USER_ID: &str = "survey_user_id";
|
pub const SURVEY_USER_ID: &str = "survey_user_id";
|
||||||
|
|
||||||
pub mod routes {
|
pub mod routes {
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use actix_auth_middleware::GetLoginRoute;
|
use actix_auth_middleware::GetLoginRoute;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Benches {
|
pub struct Benches {
|
||||||
pub submit: &'static str,
|
pub submit: &'static str,
|
||||||
pub register: &'static str,
|
pub register: &'static str,
|
||||||
|
@ -125,7 +127,7 @@ pub mod runners {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[my_codegen::get(path = "crate::V1_API_ROUTES.benches.register")]
|
#[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.benches.register")]
|
||||||
async fn register(
|
async fn register(
|
||||||
data: AppData,
|
data: AppData,
|
||||||
session: Session,
|
session: Session,
|
||||||
|
@ -178,7 +180,7 @@ pub struct SubmissionProof {
|
||||||
fn is_session_authenticated(r: &HttpRequest, mut pl: &mut Payload) -> bool {
|
fn is_session_authenticated(r: &HttpRequest, mut pl: &mut Payload) -> bool {
|
||||||
use actix_web::FromRequest;
|
use actix_web::FromRequest;
|
||||||
matches!(
|
matches!(
|
||||||
Session::from_request(&r, &mut pl).into_inner().map(|x| {
|
Session::from_request(r, pl).into_inner().map(|x| {
|
||||||
let val = x.get::<String>(SURVEY_USER_ID);
|
let val = x.get::<String>(SURVEY_USER_ID);
|
||||||
println!("{:#?}", val);
|
println!("{:#?}", val);
|
||||||
val
|
val
|
||||||
|
@ -196,7 +198,7 @@ pub fn get_check_login() -> Authentication<routes::Benches> {
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
#[my_codegen::post(
|
#[actix_web_codegen_const_routes::post(
|
||||||
path = "crate::V1_API_ROUTES.benches.submit",
|
path = "crate::V1_API_ROUTES.benches.submit",
|
||||||
wrap = "get_check_login()"
|
wrap = "get_check_login()"
|
||||||
)]
|
)]
|
||||||
|
@ -307,7 +309,7 @@ pub struct BenchConfig {
|
||||||
pub difficulties: Vec<i32>,
|
pub difficulties: Vec<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[my_codegen::get(
|
#[actix_web_codegen_const_routes::get(
|
||||||
path = "crate::V1_API_ROUTES.benches.fetch",
|
path = "crate::V1_API_ROUTES.benches.fetch",
|
||||||
wrap = "get_check_login()"
|
wrap = "get_check_login()"
|
||||||
)]
|
)]
|
||||||
|
|
|
@ -29,6 +29,9 @@ pub struct BuildDetails {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod routes {
|
pub mod routes {
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Meta {
|
pub struct Meta {
|
||||||
pub build_details: &'static str,
|
pub build_details: &'static str,
|
||||||
pub health: &'static str,
|
pub health: &'static str,
|
||||||
|
@ -45,7 +48,7 @@ pub mod routes {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// emmits build details of the bninary
|
/// emmits build details of the bninary
|
||||||
#[my_codegen::get(path = "crate::V1_API_ROUTES.meta.build_details")]
|
#[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.meta.build_details")]
|
||||||
async fn build_details() -> impl Responder {
|
async fn build_details() -> impl Responder {
|
||||||
let build = BuildDetails {
|
let build = BuildDetails {
|
||||||
version: VERSION,
|
version: VERSION,
|
||||||
|
@ -61,7 +64,7 @@ pub struct Health {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// checks all components of the system
|
/// checks all components of the system
|
||||||
#[my_codegen::get(path = "crate::V1_API_ROUTES.meta.health")]
|
#[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.meta.health")]
|
||||||
async fn health(data: AppData) -> impl Responder {
|
async fn health(data: AppData) -> impl Responder {
|
||||||
use sqlx::Connection;
|
use sqlx::Connection;
|
||||||
|
|
||||||
|
@ -87,6 +90,7 @@ mod tests {
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::api::v1::services;
|
use crate::api::v1::services;
|
||||||
|
use crate::tests::get_test_data;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
|
@ -106,7 +110,7 @@ mod tests {
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn health_works() {
|
async fn health_works() {
|
||||||
println!("{}", V1_API_ROUTES.meta.health);
|
println!("{}", V1_API_ROUTES.meta.health);
|
||||||
let data = Data::new().await;
|
let data = get_test_data().await;
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|
||||||
let resp = test::call_service(
|
let resp = test::call_service(
|
||||||
|
|
|
@ -14,12 +14,15 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
use super::admin::routes::Admin;
|
use super::admin::routes::Admin;
|
||||||
use super::bench::routes::Benches;
|
use super::bench::routes::Benches;
|
||||||
use super::meta::routes::Meta;
|
use super::meta::routes::Meta;
|
||||||
|
|
||||||
pub const ROUTES: Routes = Routes::new();
|
pub const ROUTES: Routes = Routes::new();
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
|
||||||
pub struct Routes {
|
pub struct Routes {
|
||||||
pub admin: Admin,
|
pub admin: Admin,
|
||||||
pub meta: Meta,
|
pub meta: Meta,
|
||||||
|
|
Loading…
Add table
Reference in a new issue