- Added `resources` field in `management.register` for defining browser-accessible resources. - Updated examples and documentation to reflect resource-based paths under `/v0/resource/plugins/<pluginID>/...`. - Replaced legacy `GET` menu routes with resource-based implementations for consistent plugin behavior. - Enhanced request handling for resource paths, including proper response headers and streamlined test coverage.
Showing the changes to examples/plugin/simple/rust/src (1 of 22 files). Show all
Unified · Split
| @@ -18,7 +18,7 @@ const FRONTEND_AUTH_RESPONSE: &str = r#"{"ok":true,"result":{"Authenticated":tru · 17 unmodified lines | ||
| 18 | 18 | const STREAM_RESPONSE: &str = r#"{"ok":true,"result":{"headers":{"content-type":["text/event-stream"]},"chunks":[{"Payload":"cGx1Z2luLWV4YW1wbGUtcnVzdAo="}]}}"#; |
| 19 | 19 | const CLI_REGISTER_RESPONSE: &str = r#"{"ok":true,"result":{"Flags":[{"Name":"plugin-example-rust-command","Usage":"Run the example Rust ABI plugin command","Type":"bool"}]}}"#; |
| 20 | 20 | const CLI_EXECUTE_RESPONSE: &str = r#"{"ok":true,"result":{"Stdout":"cGx1Z2luIGV4YW1wbGUgcnVzdCBjb21tYW5kCg==","ExitCode":0}}"#; |
| 21 | −const MANAGEMENT_REGISTER_RESPONSE: &str = r#"{"ok":true,"result":{"Routes":[{"Method":"GET","Path":"/plugins/example-rust/status","Menu":"Example Rust Plugin","Description":"Shows example Rust plugin status."}]}}"#; | |
| 21 | +const MANAGEMENT_REGISTER_RESPONSE: &str = r#"{"ok":true,"result":{"Resources":[{"Path":"/status","Menu":"Example Rust Plugin","Description":"CPA exposes this menu resource under /v0/resource/plugins/example-rust/status."}]}}"#; | |
| 22 | 22 | const UNKNOWN_METHOD_RESPONSE: &str = r#"{"ok":false,"error":{"code":"unknown_method","message":"unknown method"}}"#; |
| 23 | 23 | const INVALID_METHOD_RESPONSE: &str = r#"{"ok":false,"error":{"code":"invalid_method","message":"method is required"}}"#; |
| 24 | 24 | |
| @@ -170,7 +170,7 @@ fn make_http_response(request: &[u8]) -> String { · 145 unmodified lines | ||
| 170 | 170 | let method = extract_json_string(&json, "Method").unwrap_or_else(|| "GET".to_string()); |
| 171 | 171 | let target = extract_json_string(&json, "URL") |
| 172 | 172 | .or_else(|| extract_json_string(&json, "Path")) |
| 173 | − .unwrap_or_else(|| "/plugins/example-rust/status".to_string()); | |
| 173 | + .unwrap_or_else(|| "/v0/resource/plugins/example-rust/status".to_string()); | |
| 174 | 174 | let body = format!( |
| 175 | 175 | r#"{{"plugin":"example-rust","method":"{}","target":"{}"}}"#, |
| 176 | 176 | json_escape(&method), |