config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	// URL pattern to call (can include path parameters) - optional, defaults to endpoint path
	URLPattern string `yaml:"url_pattern,omitempty"`

	// Encoding for this specific backend (overrides endpoint encoding)
	Encoding string `yaml:"encoding"`

	// Host for this backend
	Host string `yaml:"host"`

	// Headers to remove before making the request to this backend
	RemoveHeaders []string `yaml:"remove_headers,omitempty"`

	// Response transformations
	Group   string            `yaml:"group,omitempty"`
	Target  string            `yaml:"target,omitempty"`
	Allow   []string          `yaml:"allow,omitempty"`
	Deny    []string          `yaml:"deny,omitempty"`
	Mapping map[string]string `yaml:"mapping,omitempty"`
	Concat  string            `yaml:"concat,omitempty"`
}

Backend represents a backend service configuration

type Config

type Config struct {
	// Global timeout for all endpoints (can be overridden per endpoint)
	Timeout time.Duration `yaml:"timeout"`

	// Service configuration
	Port            string        `yaml:"port"`
	LogLevel        string        `yaml:"log_level"`
	LogFormat       string        `yaml:"log_format"`
	ShutdownTimeout time.Duration `yaml:"shutdown_timeout"`

	// OpenTelemetry configuration
	TracingEnabled  bool   `yaml:"tracing_enabled"`
	TracingEndpoint string `yaml:"tracing_endpoint"`
	MetricsEnabled  bool   `yaml:"metrics_enabled"`
	ServiceName     string `yaml:"service_name"`

	// Endpoints configuration
	Endpoints []Endpoint `yaml:"endpoints"`
}

Config represents the entire service configuration

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig loads configuration from a YAML file

func LoadConfigFromEnv

func LoadConfigFromEnv() (*Config, error)

LoadConfigFromEnv loads configuration from environment variables

type Endpoint

type Endpoint struct {
	// Endpoint path (can include path parameters like {user})
	Endpoint string `yaml:"endpoint"`

	// HTTP method (GET, POST, PUT, DELETE, etc.)
	Method string `yaml:"method"`

	// Timeout for this specific endpoint (overrides global timeout)
	Timeout time.Duration `yaml:"timeout"`

	// Default encoding for backends (json, xml, yaml)
	Encoding string `yaml:"encoding"`

	// Backend services to aggregate
	Backends []Backend `yaml:"backends"`
}

Endpoint represents a single API endpoint configuration

Jump to

Keyboard shortcuts

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