httpapi

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package httpapi owns the ProductCore and MCP HTTP protocol adapters.

Index

Constants

View Source
const (
	MCPProtocolVersion = "2025-06-18"

	JSONRPCParseError     = -32700
	JSONRPCInvalidRequest = -32600
	JSONRPCMethodNotFound = -32601
	JSONRPCInvalidParams  = -32602
)

Variables

This section is empty.

Functions

func BearerToken

func BearerToken(header string) string

BearerToken reads the existing case-sensitive Authorization scheme.

func FirstForwardedValue

func FirstForwardedValue(value string) string

FirstForwardedValue returns the first comma-separated proxy value.

func HealthHandler

func HealthHandler(buildInfo BuildInfoProvider) http.HandlerFunc

HealthHandler exposes the additive build and schema metadata contract.

func IsAutoHomeserver

func IsAutoHomeserver(value string) bool

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

func RequestBaseURL(r *http.Request) string

RequestBaseURL returns the request-facing origin, including the first forwarded values used by the existing deployment contract.

func ResponseForRequest

func ResponseForRequest(r *http.Request, response any) any

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.

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, value any)

WriteJSON writes a JSON response using the existing transport behavior.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL