fix gurtca post_json func
This commit is contained in:
@@ -189,4 +189,8 @@ impl GurtCAClient {
|
||||
anyhow::bail!("HTTP bootstrap failed: {}", response.status())
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn post_json<T: serde::Serialize>(&self, url: &str, data: &T) -> Result<GurtResponse> {
|
||||
self.gurt_client.post_json(url, data).await.map_err(Into::into)
|
||||
}
|
||||
}
|
||||
@@ -631,12 +631,12 @@ mod tests {
|
||||
async fn test_url_parsing() {
|
||||
let client = GurtClient::new();
|
||||
|
||||
let (host, port, path) = client.parse_url("gurt://example.com/test").unwrap();
|
||||
let (host, port, path) = client.parse_gurt_url("gurt://example.com/test").unwrap();
|
||||
assert_eq!(host, "example.com");
|
||||
assert_eq!(port, DEFAULT_PORT);
|
||||
assert_eq!(path, "/test");
|
||||
|
||||
let (host, port, path) = client.parse_url("gurt://example.com:8080/api/v1").unwrap();
|
||||
let (host, port, path) = client.parse_gurt_url("gurt://example.com:8080/api/v1").unwrap();
|
||||
assert_eq!(host, "example.com");
|
||||
assert_eq!(port, 8080);
|
||||
assert_eq!(path, "/api/v1");
|
||||
|
||||
@@ -570,10 +570,16 @@ mod tests {
|
||||
assert!(!route.matches(&GurtMethod::POST, "/test"));
|
||||
assert!(!route.matches(&GurtMethod::GET, "/other"));
|
||||
|
||||
assert!(!route.matches(&GurtMethod::GET, "/test?foo=bar"));
|
||||
assert!(!route.matches(&GurtMethod::GET, "/test?page=1&limit=100"));
|
||||
|
||||
let wildcard_route = Route::get("/api/*");
|
||||
assert!(wildcard_route.matches(&GurtMethod::GET, "/api/users"));
|
||||
assert!(wildcard_route.matches(&GurtMethod::GET, "/api/posts"));
|
||||
assert!(!wildcard_route.matches(&GurtMethod::GET, "/other"));
|
||||
|
||||
assert!(wildcard_route.matches(&GurtMethod::GET, "/api/users?id=123"));
|
||||
assert!(wildcard_route.matches(&GurtMethod::GET, "/api/posts?page=2"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user