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"