soaprs_http/capability.rs
1//! Runtime enforcement capabilities required by endpoint declarations.
2
3use std::fmt;
4
5/// External runtime behavior that a framework adapter must actively provide.
6///
7/// These capabilities are distinct from response policies implemented directly
8/// by an adapter and from observational telemetry. An endpoint declaring one of
9/// these behaviors must not be served when no installed extension provides it.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
11pub enum HttpEnforcementCapability {
12 /// Credential extraction, authentication, and authorization.
13 Authentication,
14 /// Evaluation of logical request contracts.
15 RequestValidation,
16 /// Enforcement of the declared request quota.
17 RateLimit,
18 /// Cross-origin request and preflight enforcement.
19 Cors,
20 /// Cross-site request-forgery validation.
21 Csrf,
22}
23
24impl fmt::Display for HttpEnforcementCapability {
25 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
26 formatter.write_str(match self {
27 Self::Authentication => "authentication",
28 Self::RequestValidation => "request validation",
29 Self::RateLimit => "rate limiting",
30 Self::Cors => "CORS",
31 Self::Csrf => "CSRF",
32 })
33 }
34}