Skip to content

API Configuration

Anthony Bible edited this page Aug 25, 2025 · 1 revision

API Configuration

Keys

  • api.host (string): Listen address (default 0.0.0.0)
  • api.port (string): Listen port (default 8080)
  • api.read_timeout (duration): Read timeout (default 10s)
  • api.write_timeout (duration): Write timeout (default 10s)
  • api.enable_default_middleware (bool, optional): Enable the default middleware bundle (default true)
  • api.enable_cors (bool, optional): Enable CORS middleware (default true)
  • api.enable_security_headers (bool, optional): Enable security headers (default true)
  • api.enable_logging (bool, optional): Enable request/response logging (default true)
  • api.enable_error_handling (bool, optional): Enable error handling middleware (default true)

Notes

  • If a middleware toggle is omitted, the system enables it by default.
  • All middleware defaults are defined in code and can be overridden via config or env.

Environment variables

  • CODECHUNK_API_HOST
  • CODECHUNK_API_PORT
  • CODECHUNK_API_ENABLE_DEFAULT_MIDDLEWARE
  • CODECHUNK_API_ENABLE_CORS
  • CODECHUNK_API_ENABLE_SECURITY_HEADERS
  • CODECHUNK_API_ENABLE_LOGGING
  • CODECHUNK_API_ENABLE_ERROR_HANDLING

Example (YAML)

api:
  host: 0.0.0.0
  port: 8080
  read_timeout: 15s
  write_timeout: 15s
  enable_default_middleware: true
  enable_cors: true
  enable_security_headers: true
  enable_logging: true
  enable_error_handling: true

Example (ENV)

export CODECHUNK_API_PORT=9090
export CODECHUNK_API_ENABLE_SECURITY_HEADERS=false

See also

Source files

  • internal/config/config.go (APIConfig)
  • cmd/root.go (defaults, env binds for middleware)
  • cmd/api.go (middleware defaults and toggle logic)

Clone this wiki locally