hecate_plugin_routes (hecate_sdk v0.6.2)
View SourceRoute discovery for plugin API handlers.
Discovers Cowboy route tuples from OTP application metadata. Each domain app that exports routes/0 from any of its modules contributes routes automatically.
Plugins call discover_routes/1 in their routes/0 callback:
routes() -> hecate_plugin_routes:discover_routes(MyDomainApps).
Routes returned by domain handlers use "/api/" prefix (for standalone mode). The plugin loader mounts at /plugin/{name}/api/, so strip_api_prefix/1 removes the leading "/api" to avoid double nesting.
Summary
Functions
Discover all routes from a list of OTP application names. Scans each app's modules for those exporting routes/0 and collects all returned route tuples.
Strip leading "/api" from a route path. Domain handlers define routes with "/api/..." prefix for standalone use. When mounted as a plugin under /plugin/{name}/api/, the prefix must be removed to avoid /plugin/{name}/api/api/... paths.
Functions
Discover all routes from a list of OTP application names. Scans each app's modules for those exporting routes/0 and collects all returned route tuples.
Strip leading "/api" from a route path. Domain handlers define routes with "/api/..." prefix for standalone use. When mounted as a plugin under /plugin/{name}/api/, the prefix must be removed to avoid /plugin/{name}/api/api/... paths.