Documentation
¶
Overview ¶
Package edge is the gate in front of the gateway's two HTTP entrances: /mcp for agents and /edi/inbound for partners (the second is in internal/inbound).
Input: every HTTP request to either entrance. Output: either an error response in the gateway's single format (internal/rpcerr) or the request passed on with the caller's identity attached.
Gate holds what both entrances share: the bucket per client address (spent only by failed token checks), the bearer token -> principal step (tenant and kind come only from the database) and the buckets per principal and per partner. The /mcp handler (Gate.MCP) adds, in this order, all before the SDK sees the request:
- only kind "agent" may use /mcp
- bucket per principal
- body size, single JSON-RPC object, Mcp-Method / Mcp-Name against the body
Every request gets a trace id (header Edigate-Trace-Id). The identity reaches tool handlers as the SDK's RequestExtra.TokenInfo; see Identity.
Index ¶
- type Caller
- type Gate
- func (g *Gate) AllowPartner(tenantID, partnerID string) bool
- func (g *Gate) Authenticate(w http.ResponseWriter, r *http.Request) (Caller, bool)
- func (g *Gate) MCP(next http.Handler) *Handler
- func (g *Gate) Reject(w http.ResponseWriter, trace, principal string, reason rpcerr.Reason, ...)
- func (g *Gate) RejectTooLarge(w http.ResponseWriter, trace, principal string)
- type Handler
- type Identity
- type PrincipalFinder
- type TransportLog
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Gate ¶
type Gate struct {
// contains filtered or unexported fields
}
Gate is the part of the edge that /mcp and /edi/inbound share.
func (*Gate) AllowPartner ¶
AllowPartner takes one token from the bucket of a partner (2 interchanges per second, burst 2) and reports whether there was one.
func (*Gate) Authenticate ¶
Authenticate runs the steps both entrances share: sets the trace id header, checks the bucket of the client address and resolves the bearer token. On failure it writes the error response and returns false.
func (*Gate) Reject ¶
func (g *Gate) Reject(w http.ResponseWriter, trace, principal string, reason rpcerr.Reason, id json.RawMessage)
Reject logs and writes an error in the gateway's single format.
func (*Gate) RejectTooLarge ¶
func (g *Gate) RejectTooLarge(w http.ResponseWriter, trace, principal string)
RejectTooLarge answers a body over the limit: HTTP 413 and schema_invalid.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is the /mcp middleware.
type PrincipalFinder ¶
type PrincipalFinder interface {
FindPrincipal(ctx context.Context, tokenSHA256 []byte) (store.Principal, error)
}
PrincipalFinder looks a principal up by token hash. It returns store.ErrNotFound for unknown and revoked tokens.
type TransportLog ¶
type TransportLog struct {
// contains filtered or unexported fields
}
TransportLog writes one JSON line for every request that goes through it (EDIGATE_TRANSPORT_LOG, protocol item O3): the time, the trace id, the MCP method, the tool, the body of the request and the body of the answer. It is for the stand only: the bodies hold the data of the benchmark, which is synthetic. It wraps the /mcp handler from outside, so a request that the edge refuses is in the log too.
func OpenTransportLog ¶
func OpenTransportLog(path string) (*TransportLog, error)
OpenTransportLog opens (and creates) the file in append mode.