1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Maintenance mode middleware.
//!
//! Set `MAINTENANCE_MODE` to `true` at runtime to return `503 Service
//! Unavailable` for all requests except `/healthz` and `/readyz`. Clear it to
//! resume normal traffic.
//!
//! # Example
//!
//! ```rust,no_run
//! use rust_web_server::app::App;
//! use rust_web_server::core::New;
//! use rust_web_server::maintenance::{MAINTENANCE_MODE, MaintenanceLayer};
//! use std::sync::atomic::Ordering;
//!
//! let app = App::new().wrap(MaintenanceLayer);
//!
//! // Enable maintenance mode at runtime.
//! MAINTENANCE_MODE.store(true, Ordering::SeqCst);
//! ```
use ;
use crateApplication;
use crateNew as _;
use crateMiddleware;
use crateRequest;
use crate;
use crateRange;
use crateMimeType;
use crateConnectionInfo;
/// Flip to `true` to activate maintenance mode; back to `false` to resume.
pub static MAINTENANCE_MODE: AtomicBool = new;
/// Middleware that returns `503` when [`MAINTENANCE_MODE`] is `true`.
///
/// Health probe paths (`/healthz`, `/readyz`) always pass through so that
/// load balancers can still detect the pod is alive.
;