Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New() httpserver.HandlerFunc
New creates a middleware that transforms all responses to JSON format. Non-JSON responses are wrapped in {"response": "content"}. Valid JSON responses are preserved as-is.
Types ¶
type ResponseBuffer ¶
type ResponseBuffer struct {
// contains filtered or unexported fields
}
ResponseBuffer captures response data for transformation
This is a simple example for demonstration purposes and is not intended for production use. Limitations: - Does not preserve optional HTTP interfaces (http.Hijacker, http.Flusher, http.Pusher) - Not safe for concurrent writes from multiple goroutines within the same request - No memory limits on buffered content
Each request gets its own ResponseBuffer instance, so different requests won't interfere with each other.
func NewResponseBuffer ¶
func NewResponseBuffer() *ResponseBuffer
NewResponseBuffer creates a new response buffer
func (*ResponseBuffer) Header ¶
func (rb *ResponseBuffer) Header() http.Header
Header implements http.ResponseWriter
func (*ResponseBuffer) Size ¶
func (rb *ResponseBuffer) Size() int
Size implements httpserver.ResponseWriter
func (*ResponseBuffer) Status ¶
func (rb *ResponseBuffer) Status() int
Status implements httpserver.ResponseWriter
func (*ResponseBuffer) Write ¶
func (rb *ResponseBuffer) Write(data []byte) (int, error)
Write implements http.ResponseWriter
func (*ResponseBuffer) WriteHeader ¶
func (rb *ResponseBuffer) WriteHeader(statusCode int)
WriteHeader implements http.ResponseWriter
func (*ResponseBuffer) Written ¶
func (rb *ResponseBuffer) Written() bool
Written implements httpserver.ResponseWriter