apiresponse

package
v1.153.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package apiresponse holds the API gateway's rules for an upstream response: which bodies are safe to return inline, and which headers reach the caller. Moved out of pkg/toolkits/apigateway for its size budget.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Headers

func Headers(h http.Header) map[string][]string

Headers is the subset of h in the passthrough set, nil when none.

func Inlineable

func Inlineable(contentType string) bool

Inlineable reports whether a response with this Content-Type is safe to buffer and return inline through the MCP/JSON channel. Text-shaped bodies (text/*, JSON, XML, form, JavaScript) are inlineable: JSON-escaping them is roughly size-preserving. Binary bodies (application/zip, application/octet-stream, image/*, audio/*, video/*, application/pdf, ...) are NOT: json.Marshal escapes every control and invalid-UTF-8 byte as \uXXXX, inflating a high-entropy body several-fold, and the escaped copy is held alongside the raw buffer and the re-marshaled MCP envelope. Returning such a body inline both risks an OOM and is useless to the model. The gateway refuses those before buffering and steers the caller to api_export.

An empty or unparseable Content-Type returns true so the legacy buffered path (bounded by the per-request read cap) is unchanged for responses that declare no usable type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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