Documentation
¶
Overview ¶
Package httpapi owns the ProductCore and MCP HTTP protocol adapters.
Index ¶
- Constants
- func BearerToken(header string) string
- func FirstForwardedValue(value string) string
- func HealthHandler(buildInfo BuildInfoProvider, readiness ...func() error) http.HandlerFunc
- func IsAutoHomeserver(value string) bool
- func MCPHandler(cfg MCPConfig) http.HandlerFunc
- func MCPInitializeResult(buildInfo BuildInfoProvider) map[string]any
- func ProductHandler(port ProductPort) http.HandlerFunc
- func RequestBaseURL(r *http.Request) string
- func ResponseForRequest(r *http.Request, response any) any
- func SetCORSHeaders(w http.ResponseWriter, r *http.Request)
- func WellKnownHandler(wellKnown func() any) http.HandlerFunc
- func WriteError(w http.ResponseWriter, err *actionbase.Error)
- func WriteJSON(w http.ResponseWriter, status int, value any)
- type BuildInfoProvider
- type MCPConfig
- type MCPPort
- type ProductPort
Constants ¶
const ( MCPProtocolVersion = "2025-06-18" JSONRPCParseError = -32700 JSONRPCInvalidRequest = -32600 JSONRPCMethodNotFound = -32601 JSONRPCInvalidParams = -32602 )
Variables ¶
This section is empty.
Functions ¶
func BearerToken ¶
BearerToken reads the existing case-sensitive Authorization scheme.
func FirstForwardedValue ¶
FirstForwardedValue returns the first comma-separated proxy value.
func HealthHandler ¶
func HealthHandler(buildInfo BuildInfoProvider, readiness ...func() error) http.HandlerFunc
HealthHandler exposes the additive build and schema metadata contract. The optional readiness callback lets deployments fail closed while a required external capability peer/catalog is unavailable without changing existing callers that only need build metadata.
func IsAutoHomeserver ¶
IsAutoHomeserver reports whether a configured homeserver uses the auto host.
func MCPHandler ¶
func MCPHandler(cfg MCPConfig) http.HandlerFunc
MCPHandler implements the existing MCP Streamable HTTP request/response subset. Server-to-client GET streaming remains intentionally disabled.
func MCPInitializeResult ¶
func MCPInitializeResult(buildInfo BuildInfoProvider) map[string]any
MCPInitializeResult returns the canonical MCP server capabilities payload.
func ProductHandler ¶
func ProductHandler(port ProductPort) http.HandlerFunc
ProductHandler handles both ProductCore query and command envelopes. Route method selection remains owned by the outer router.
func RequestBaseURL ¶
RequestBaseURL returns the request-facing origin, including the first forwarded values used by the existing deployment contract.
func ResponseForRequest ¶
ResponseForRequest resolves an auto homeserver against the inbound request. The original response map is not mutated.
func SetCORSHeaders ¶
func SetCORSHeaders(w http.ResponseWriter, r *http.Request)
SetCORSHeaders preserves the shared ProductCore transport CORS contract.
func WellKnownHandler ¶
func WellKnownHandler(wellKnown func() any) http.HandlerFunc
WellKnownHandler exposes the public owner profile discovery payload.
func WriteError ¶
func WriteError(w http.ResponseWriter, err *actionbase.Error)
WriteError writes the ProductCore HTTP error envelope.
Types ¶
type BuildInfoProvider ¶
type BuildInfoProvider func() rootinternal.BuildInfo
BuildInfoProvider supplies release metadata to public protocol responses. A nil provider uses the process build metadata.
type MCPConfig ¶
type MCPConfig struct {
Port MCPPort
BuildInfo BuildInfoProvider
}
MCPConfig configures the MCP Streamable HTTP adapter.
type MCPPort ¶
type MCPPort interface {
TokenAuthorized(token string) bool
Tools() []dirextalkmcp.Tool
Invoke(ctx context.Context, action string, params map[string]any) (any, *dirextalkmcp.Error)
}
MCPPort is the narrow capability required by the Streamable HTTP adapter.
type ProductPort ¶
type ProductPort interface {
HasAction(action string) bool
Authorize(ctx context.Context, token, action string) (context.Context, bool)
Handle(ctx context.Context, action string, params map[string]any) (any, *actionbase.Error)
CreateWSTicket(token string) (any, *actionbase.Error)
}
ProductPort is the narrow root capability required by the ProductCore HTTP adapter. Authorize may return a context carrying an authenticated session.