headless_lms_server/controllers/mock_suotar/mod.rs
1/*!
2Mock Suotar: a stand-in for the University of Helsinki Suotar API, and the test/dev control surface
3around it.
4
5Mounted at `/api/v0/mock-suotar` only when `TEST_MODE` and `USE_MOCK_SUOTAR_ENDPOINT` are both on.
6Like `mock_sisu` and `mock_azure`, the gate is runtime registration rather than `#[cfg]`: the code
7always compiles, but with the flags off the routes are absent from the route table.
8
9`SUOTAR_API_BASE_URL` and `SUOTAR_API_KEY` are deliberately unset in the dev and test overlays, so
10the production path is known to fail loudly when unconfigured.
11*/
12
13pub mod control;
14
15use crate::prelude::*;
16
17/// The route cannot be reached with the flags off, so tripping this means the gate itself broke.
18pub fn assert_enabled(app_conf: &ApplicationConfiguration) {
19 assert!(app_conf.test_mode && app_conf.test_suotar);
20}
21
22pub fn _add_routes(cfg: &mut ServiceConfig) {
23 cfg.service(web::scope("/control").configure(control::_add_routes));
24}