headless_lms_server/controllers/mock_suotar/
mod.rs1pub mod api;
11pub mod commands;
12pub mod control;
13
14use actix_web::{Resource, Scope};
15
16use crate::prelude::*;
17
18pub fn assert_enabled(app_conf: &ApplicationConfiguration) {
20 assert!(app_conf.test_mode && app_conf.test_suotar);
21}
22
23pub fn scope() -> Scope {
26 web::scope("/mock-suotar")
27 .service(
28 web::scope("/control")
29 .configure(control::_add_routes)
30 .default_service(web::to(HttpResponse::NotFound)),
31 )
32 .service(
33 contract_route("/persons/resolve-by-student-numbers")
34 .route(web::post().to(api::resolve_persons)),
35 )
36 .service(
37 contract_route("/enrolments/resolve").route(web::post().to(api::resolve_enrolments)),
38 )
39 .service(
40 contract_route("/enrolments/list-by-course").route(web::post().to(api::list_by_course)),
41 )
42 .service(
43 contract_route("/attainments/import").route(web::post().to(api::import_attainments)),
44 )
45 .service(
46 contract_route("/attainments/verify").route(web::post().to(api::verify_attainments)),
47 )
48 .service(
49 contract_route("/course-codes/validate")
50 .route(web::post().to(api::validate_course_codes)),
51 )
52 .default_service(web::to(api::fall_through))
53}
54
55fn contract_route(path: &str) -> Resource {
56 web::resource(path).default_service(web::to(api::fall_through))
57}