Skip to main content

http_contract

Function http_contract 

Source
pub fn http_contract(method: &str, path_or_url: &str) -> String
Expand description

Build a normalized HTTP contract key from a method and a path (or full URL). A client call and a server route for the same endpoint must produce the same string: the method is upper-cased, any scheme+host is stripped, path parameters ({id}, :id, <id>, <int:id>) collapse to {}, query and fragment are dropped, and trailing slashes are removed.

use agentstatedeveloper_core::cross_service::http_contract;
assert_eq!(http_contract("post", "/Users/{id}/"), "http:POST /users/{}");
assert_eq!(http_contract("GET", "https://api.svc/users/:id?x=1"), "http:GET /users/{}");