Skip to main content

normalize_binding

Function normalize_binding 

Source
pub fn normalize_binding(
    method: &str,
    path: &str,
    query: &str,
) -> Result<String, AshError>
Expand description

Normalize a binding string to canonical form (v2.3.2+ format).

Bindings are in the format: METHOD|PATH|CANONICAL_QUERY

§Normalization Rules

  • Method is uppercased
  • Path must start with /
  • Path has duplicate slashes collapsed
  • Trailing slash is removed (except for root /)
  • Query string is canonicalized (sorted, normalized)
  • Parts are joined with | (pipe) separator

§Example

use ash_core::normalize_binding;

let binding = normalize_binding("post", "/api//users/", "").unwrap();
assert_eq!(binding, "POST|/api/users|");

let binding_with_query = normalize_binding("GET", "/api/users", "page=1&sort=name").unwrap();
assert_eq!(binding_with_query, "GET|/api/users|page=1&sort=name");