pub struct RoutingTable { /* private fields */ }Expand description
The parsed routing table (Java RoutingEntry).
Implementations§
Source§impl RoutingTable
impl RoutingTable
Sourcepub fn load(reader: &ConfigReader) -> Result<Self, AppError>
pub fn load(reader: &ConfigReader) -> Result<Self, AppError>
Load and validate a rest.yaml (Java RoutingEntry.load). Invalid
entries fail the load — the grammar’s parser invariants.
Sourcepub fn retain_available(
&mut self,
is_registered: impl Fn(&str) -> bool,
) -> Vec<(String, String, String)>
pub fn retain_available( &mut self, is_registered: impl Fn(&str) -> bool, ) -> Vec<(String, String, String)>
Drop every entry whose target is a function route that is not
registered, the way Java’s RoutingEntry.resolveServices does at load
(po.exists(service), else “Skip [methods] url - Service x not
available” as a warning). An entry whose backing function was left out,
such as an #[optional_service] whose condition is false or a typo,
must not become a live URL that answers “Route … not found”. HTTP(S)
targets are not routes and are never checked. Returns the skipped
entries’ ("[methods]", url, service) for the caller to log.
Sourcepub fn static_content(&self) -> &StaticContent
pub fn static_content(&self) -> &StaticContent
The static-content configuration (defaults applied when absent).
Sourcepub fn from_yaml_text(yaml: &str) -> Result<Self, AppError>
pub fn from_yaml_text(yaml: &str) -> Result<Self, AppError>
Build a routing table from YAML text (used for the built-in default endpoints — same parser, same invariants).
pub fn routes(&self) -> &[RouteInfo]
Sourcepub fn has_url(&self, url: &str) -> bool
pub fn has_url(&self, url: &str) -> bool
Whether any entry already claims this URL (used by the default-endpoint
merge: user entries always win — Java default-rest.yaml semantics).
Sourcepub fn find(&self, method: &str, path: &str) -> Option<AssignedRoute<'_>>
pub fn find(&self, method: &str, path: &str) -> Option<AssignedRoute<'_>>
Match a request (Java getRouteInfo): candidates must match every
segment; precedence is more literal segments first, wildcard last.
Method filtering happens here too — OPTIONS matches any entry (CORS
preflight, auto-added per the grammar).
Sourcepub fn path_matches_any_method(&self, path: &str) -> bool
pub fn path_matches_any_method(&self, path: &str) -> bool
True when the path matches SOME entry regardless of method — the Java
getSimilarRoute marker (increment 56, parity F14c): a known path
with a wrong method answers 405 “Method not allowed”, never 404.