Файли
openidea/sdk/rust/openidea-plugin/src/endpoints.rs
T
Arnaud Ritti 668206ddfd feat(plugins): share project HTTP endpoints with the HTTP client (#1991)
Adds the API 1.3 `endpoints-provider` export and `[[contributes.endpoints]]` (file globs, ^1.3, `project.read`). A plugin's routes join the Spring ones in Search Everywhere, `.http` URL completion and the declaration's Open in HTTP Client gutter action. The UI asks `plugin_endpoints` on demand; the host runs the plugin on a blocking thread, validates the whole list (bounds, project-relative locations, UTF-16 ranges) and caches it per project until a file matching the globs changes, then emits `EndpointsChanged`. A failed or invalid run keeps the last list; disabling, crashing or closing the project withdraws it, and late results can't restore it. Closes #1960.

Co-authored-by: arnaud-ritti <[email protected]>
2026-11-07 22:59:21 +08:00

20 рядки
684 B
Rust

//! Project HTTP routes for Search Everywhere and the HTTP client.
use crate::{Error, Invocation, Location};
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Endpoint {
/// `None` accepts any HTTP method.
pub method: Option<String>,
pub path: String,
pub framework: String,
pub handler: Option<String>,
/// Declaration range, with zero-based lines and UTF-16 columns.
pub location: Location,
}
/// Register with `register_plugin!(MyPlugin, endpoints)` and declare
/// `[[contributes.endpoints]] files = ["config/routes.rb"]` in the manifest.
pub trait EndpointsProvider {
fn endpoints(&mut self, ctx: &Invocation) -> Result<Vec<Endpoint>, Error>;
}