failapi

package
v0.20.8 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package failapi is the injected-failure half of a fault-injection stand-in for the Anthropic API: every request it serves gets one status, an Anthropic-shaped error body and any extra response headers. The rig's failproxy binary and the canary's zero-token failure runs both serve it, so the error body is written in exactly one place.

It never reads request headers: pointed at by ANTHROPIC_BASE_URL under subscription OAuth, the Authorization header on every request carries a live token.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(f Failure) http.Handler

Handler serves f to every request.

Types

type Failure

type Failure struct {
	Status  int
	Type    string      // the error body's error.type, e.g. "api_error"
	Message string      // error.message; some StopFailure mappings key on it
	Headers [][2]string // extra response headers as name, value pairs
	// Hold delays the response, so the request stays in flight and a turn has produced no
	// output yet; it ends early when the client gives up on the request.
	Hold time.Duration
}

Failure is one injected response.

func (Failure) Serve

func (f Failure) Serve(w http.ResponseWriter, r *http.Request)

Serve drains r's body, so the client never sees a reset connection, waits out f.Hold, then sends f as the whole response.

Jump to

Keyboard shortcuts

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