Overviewâ
services.Route() reads dynamic route metadata attached to the current request. Source plugins access it through services.Route(), while dynamic plugins declare service: route in plugin.yaml and access it via pluginbridge.Default().Route(). This service primarily supports host audit, operation logging, or source plugin context enrichment when handling dynamic plugin requests.
Source plugins do not need RouteService to register their own routes; route registration is done through pluginhost.Declarations.HTTP().RegisterRoutes.
Capability Phase: Runtime
Supported Types: Source plugins, dynamic plugins
Capability Designâ
Metadata View Modelâ
DynamicRouteMetadata is a read-only view attached to the current request, containing full descriptive information about a dynamic route:
| Field | Description |
|---|---|
PluginID | The plugin ID that owns the current dynamic route |
Method | The HTTP method declared by the dynamic route |
PublicPath | The path exposed and matched by the host |
Tags | Tags declared by the dynamic route |
Summary | Summary declared by the dynamic route |
Meta | Plugin-defined custom route metadata |
ResponseBody | The raw response body captured by the dispatcher |
ResponseContentType | The response content type |
Route Dispatch Flowâ
Read-only Data Semanticsâ
Callers cannot modify dynamic routes or responses through this service. Non-dynamic routes return nil; callers should perform a nil check before use. ResponseBody depends on runtime capture results and should not be treated as an authoritative source of business data.
Interface Definitionsâ
Source Plugin Interfaceâ
| Method | Description |
|---|---|
DynamicRouteMetadata | Reads dynamic route metadata from context.Context; returns nil for non-dynamic routes |
Dynamic Plugin Interfaceâ
Dynamic plugins declare authorized methods through hostServices.route:
| Dynamic Method | Description |
|---|---|
metadata.get | Reads dynamic route metadata attached to the current request |
Usageâ
Source Plugin Usageâ
Source plugins read dynamic route metadata through services.Route(), with typical scenarios including audit logging and operation recording:
// Read dynamic route metadata
meta := services.Route().DynamicRouteMetadata(ctx)
if meta != nil {
// Record audit log
log.Infof("Dynamic plugin %s route %s %s was accessed", meta.PluginID, meta.Method, meta.PublicPath)
}
Source plugins register their own routes using pluginhost.Declarations.HTTP().RegisterRoutes:
plugin := pluginhost.NewDeclarations("my-author-my-domain-my-cap")
err := plugin.HTTP().RegisterRoutes(
pluginhost.ExtensionPointHTTPRouteRegister,
pluginhost.CallbackExecutionModeBlocking,
registerRoutes,
)
Dynamic Plugin Usageâ
Dynamic plugins declare the route service in plugin.yaml:
hostServices:
- service: route
methods:
- metadata.get
Dynamic plugins call through pluginbridge.Default().Route():
routeSvc := pluginbridge.Default().Route()
meta := routeSvc.DynamicRouteMetadata(ctx)
Design Constraintsâ
- Read-only data. Callers cannot modify dynamic routes or responses through this service.
- Non-dynamic routes return
nil. Callers should perform a nil check before use. - Response body may be empty.
ResponseBodydepends on runtime capture results and should not be treated as an authoritative source of business data. - Dynamic plugins read the request envelope directly. Route information within dynamic plugins comes from
BridgeRequestEnvelopeV1.Route, not from callingRouteServicethroughhostServices.