This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Couper is a lightweight API gateway written in Go. Configuration is done via HCL (HashiCorp Configuration Language) files. It provides access control, request/response manipulation, and observability features.
Detailed documentation is maintained in shared files:
- docs/ARCHITECTURE.md: Configuration flow, key packages, the Inline pattern, request processing pipeline, HCL evaluation context, improvement notes
- docs/GO_GUIDELINES.md: Error handling, context usage, interface design, DDD patterns, Go best practices
# Build the binary (with race detection)
make build
# Run with a configuration file
./couper run -f public/couper.hcl
# Run all tests
make test
# Run a single test
go test -v -timeout 90s -race -count=1 ./path/to/package -run TestName
# Run tests in a specific package
go test -v -timeout 90s -race -count=1 ./server/...
# Run tests with coverage
make coverage
# Generate code (assets and error types)
make generate
# Generate documentation (writes to docs/website/content/configuration/block/*.md)
make generate-docs
# Serve documentation locally
make serve-docs
# Update dependencies
make update-modulesTests are real integration tests - no mocking of HTTP, networking, or Couper internals:
- Open real ports and listeners
- Use actual HTTP clients and servers
- Load test fixture HCL files from
server/testdata/ - Exercise the full request/response pipeline
Mocks are rare exceptions - only for special unit test situations where isolation is absolutely necessary.
server/http_integration_test.go: Main integration test suiteserver/testdata/*.hcl: Test configuration fixturesinternal/test/backend.go: Test backend server (real HTTP server)internal/test/: Helper utilities for test setup and assertions
| Pattern | Location | Purpose |
|---|---|---|
| Inline Interface | config/inline.go |
Separates parse-time vs runtime attributes |
| Modifier Attributes | config/meta/attributes.go |
Shared request/response modifiers |
| HCL Evaluation | eval/context.go |
Expression evaluation with request context |
| Sequence Execution | handler/endpoint.go |
Parallel/sequential backend requests |
| Error Hierarchy | errors/ |
Error types for error_handler blocks |
- Error types: Generated from
errors/generate/types.goviago generate - Documentation: Generated from struct tags via
make generate-docs - Assets: Embedded via
go:embed
The project uses forked versions of hashicorp/hcl/v2 and zclconf/go-cty (see go.mod replace directives).
Before making significant changes, read:
- docs/ARCHITECTURE.md - Especially the Inline pattern section
- docs/GO_GUIDELINES.md - Error handling and interface design
config/inline.go- Core interfaceseval/http.go- Request/response context applicationhandler/endpoint.go- Request orchestration