- modules/pier: Host contract, mcp.* config, catalog compiled from pact.HasMCP (prefixing, route binding, guard resolution, schema reflection, annotations), per-request identity through the published verifier and resolvers, built-in backend guard provider, in-process dispatch with the bouncer marker, per-identity SDK server with the per-request re-filter, stateful session router with rehydration over a memory store, audit lines - modules/surf/pier_on.go: the summercms_mcp hook adapting the router to pier.Host; the untagged hello binary carries no SDK - go.mod: go-sdk v1.8.0 and jsonschema-go v0.4.3 (decision note committed before this change) - TestPierTracerSmoke: SDK client lists and calls acme_echo end to end through surf's compiled guard chain; README and root table row
34 lines
1.3 KiB
Go
34 lines
1.3 KiB
Go
package pier
|
|
|
|
import "net/http"
|
|
|
|
// Host is what pier needs from the HTTP router that mounts it, so that pier
|
|
// never imports surf (surf imports pier in a binary built with the
|
|
// summercms_mcp tag and passes an adapter). Routes lists every registered
|
|
// route, Handler returns the compiled middleware chain of one route for an
|
|
// in-process dispatch (resolved lazily, after the router has compiled),
|
|
// MountStream registers one unbuffered route under the pier pseudo-plugin,
|
|
// MountJSON registers one plain GET route for a static JSON document and
|
|
// Owner reports the plugin that registered a route, for collision checks.
|
|
type Host interface {
|
|
Routes() []RouteInfo
|
|
Handler(method, pattern string) (http.Handler, bool)
|
|
MountStream(method, path string, h http.Handler, middleware ...string) error
|
|
MountJSON(method, path string, h http.Handler) error
|
|
Owner(method, path string) (string, bool)
|
|
}
|
|
|
|
// RouteInfo is one registered route as the Host reports it: the HTTP method,
|
|
// the pattern as registered (with {param} segments), the plugin that
|
|
// registered it and its middleware names in order.
|
|
type RouteInfo struct {
|
|
Method string
|
|
Pattern string
|
|
PluginID string
|
|
Middleware []string
|
|
}
|
|
|
|
// PluginID is the pseudo-plugin id pier's own routes are registered under in
|
|
// the route table.
|
|
const PluginID = "summercms.pier"
|