config

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Overview

Package config provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.7.2 DO NOT EDIT.

Index

Constants

View Source
const (
	DefaultMetricPath = "/metrics"
)

Variables

View Source
var (
	ErrListenAddressMissing = errors.New("server.listen_address is required")
	ErrCorsBadMaxAge        = errors.New("invalid value of CORS max_age")
)

Functions

func GetSpec added in v0.0.4

func GetSpec() (swagger *openapi3.T, err error)

GetSpec returns the OpenAPI specification corresponding to the generated code in this file. External references in the spec are resolved through PathToRawSpec; externally-referenced files must be embedded in their corresponding Go packages (via the import-mapping feature). URL-based external refs are not supported.

func GetSpecJSON added in v0.0.4

func GetSpecJSON() ([]byte, error)

GetSpecJSON returns the raw JSON bytes of the embedded OpenAPI specification: decompressed but not unmarshaled. External references are not resolved here; the bytes are the spec exactly as embedded by codegen. The result is cached at package init time, so repeated calls are cheap.

func GetSwagger deprecated added in v0.0.4

func GetSwagger() (*openapi3.T, error)

GetSwagger returns the OpenAPI specification corresponding to the generated code in this file.

Deprecated: GetSwagger predates kin-openapi renaming openapi3.Swagger to openapi3.T. Use GetSpec instead. This wrapper is retained for backwards compatibility.

func PathToRawSpec added in v0.0.4

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

Types

type CorsConfig

type CorsConfig struct {
	// AllowedOrigins AllowedOrigins controls value of Access-Control-Allow-Origin header.
	AllowedOrigins []string `json:"allowed_origins" yaml:"allowed_origins"`

	// MaxAge MaxAge controls value of Access-Control-Max-Age header.
	MaxAge int `json:"max_age" yaml:"max_age"`
}

CorsConfig CORS configuration

func (*CorsConfig) BindFlags added in v0.0.2

func (c *CorsConfig) BindFlags(prefix string, pf *pflag.FlagSet)

type ServerConfig

type ServerConfig struct {
	// APIPrefix API prefix
	APIPrefix string `json:"api_prefix" yaml:"api_prefix"`

	// Cors CORS configuration
	Cors *CorsConfig `json:"cors,omitempty" yaml:"cors,omitempty"`

	// IdleTimeout Idle timeout
	IdleTimeout *time.Duration `json:"idle_timeout,omitempty" yaml:"idle_timeout,omitempty"`

	// ListenAddress Address to listen on
	ListenAddress string `json:"listen_address" yaml:"listen_address"`

	// ReadHeaderTimeout HTTP headers receive timeout
	ReadHeaderTimeout *time.Duration `json:"read_header_timeout,omitempty" yaml:"read_header_timeout,omitempty"`

	// ReadTimeout HTTP read timeout
	ReadTimeout *time.Duration `json:"read_timeout,omitempty" yaml:"read_timeout,omitempty"`

	// Telemetry Telemetry configuration
	Telemetry *TelemetryConfig `json:"telemetry,omitempty" yaml:"telemetry,omitempty"`

	// TLS TLS configuration
	TLS *TLSConfig `json:"tls,omitempty" yaml:"tls,omitempty"`

	// WriteTimeout HTTP write timeout
	WriteTimeout *time.Duration `json:"write_timeout,omitempty" yaml:"write_timeout,omitempty"`
}

ServerConfig Server configuration

func (*ServerConfig) BindFlags added in v0.0.2

func (s *ServerConfig) BindFlags(prefix string, pf *pflag.FlagSet)

func (*ServerConfig) Check

func (s *ServerConfig) Check() error

Check checks if configuration is semantically valid

func (*ServerConfig) RunForever

func (s *ServerConfig) RunForever(srv *http.Server) error

func (*ServerConfig) RunUntil

func (s *ServerConfig) RunUntil(srv *http.Server, stopCh <-chan struct{}) error

type TLSConfig

type TLSConfig struct {
	// CertFile Path to file with certificate bundle
	CertFile string `json:"cert_file" yaml:"cert_file"`

	// KeyFile Path to file with private key
	KeyFile string `json:"key_file" yaml:"key_file"`
}

TLSConfig TLS configuration

func (*TLSConfig) BindFlags added in v0.0.2

func (t *TLSConfig) BindFlags(prefix string, pf *pflag.FlagSet)

type TelemetryConfig

type TelemetryConfig struct {
	// Enabled Whether the metrics instrumentation should be enabled
	Enabled bool `json:"enabled" yaml:"enabled"`

	// Path HTTP context where metrics should be exposed
	Path string `json:"path" yaml:"path"`
}

TelemetryConfig Telemetry configuration

func (*TelemetryConfig) BindFlags added in v0.0.2

func (t *TelemetryConfig) BindFlags(prefix string, pf *pflag.FlagSet)

Jump to

Keyboard shortcuts

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