Documentation
¶
Index ¶
- Constants
- type Backend
- type BotDetectorConfig
- type CORSConfig
- type Config
- type Endpoint
- type ExtraConfig
- type GELFConfig
- type GenerateKrakenConfigOpts
- type Generator
- func (g *Generator) Description() string
- func (g *Generator) Generate(opts openapigenerator.GenerateOpts) error
- func (g *Generator) Id() string
- func (g *Generator) IsPrimitiveType(input string) bool
- func (g *Generator) PostProcessType(codeType openapigenerator.CodeType) openapigenerator.CodeType
- func (g *Generator) PostProcessing(files map[string]templateapi.RenderedFile) error
- func (g *Generator) TemplateData(opts openapigenerator.TemplateDataOpts) (openapigenerator.DocumentModel, error)
- func (g *Generator) ToClassName(name string) string
- func (g *Generator) ToCodeType(schema *base.Schema, schemaType openapigenerator.CodeTypeSchemaType, ...) (openapigenerator.CodeType, error)
- func (g *Generator) ToConstantName(name string) string
- func (g *Generator) ToFunctionName(name string) string
- func (g *Generator) ToParameterName(name string) string
- func (g *Generator) ToPropertyName(name string) string
- func (g *Generator) TypeToImport(iType openapigenerator.CodeType) string
- type KrakenDConfig
- type LoggingConfig
- type LogstashConfig
- type OTAttribute
- type OTExporters
- type OTLPExporter
- type OTLayerBackend
- type OTLayerGlobal
- type OTLayerProxy
- type OTLayers
- type OTStageDetails
- type OpenTelemetryConfig
- type OperationMeta
- type OperationSecurity
- type PrometheusExporter
- type ResolvedEndpoint
- type RouterConfig
- type SecurityHTTPConfig
Constants ¶
const ( EnvironmentDev = "dev" EnvironmentStage = "stage" EnvironmentProd = "prod" )
const ( PropEnvironments = "environments" PropServerPort = "server.port" PropServerTimeout = "server.timeout" PropServerReadTimeout = "server.readTimeout" PropServerWriteTimeout = "server.writeTimeout" PropServerIdleTimeout = "server.idleTimeout" PropServerReadHeaderTimeout = "server.readHeaderTimeout" PropServerCacheTTL = "server.cacheTTL" PropDebugEndpointEnvironments = "debugEndpoint.environments" PropEchoEndpointEnvironments = "echoEndpoint.environments" PropCORSEnabled = "cors.enabled" PropCORSAllowOrigins = "cors.allowOrigins" PropBotDetectorEnabled = "botDetector.enabled" PropCircuitBreakerEnabled = "circuitBreaker.enabled" PropLoggingLevel = "logging.level" PropPrometheusPort = "telemetry.prometheus.port" PropOTLPHost = "telemetry.otlp.host" PropOTLPPort = "telemetry.otlp.port" PropTraceSampleRate = "telemetry.traceSampleRate" PropLoggingFormat = "logging.format" PropLoggingGELFAddress = "logging.gelfAddress" PropBackendReturnErrorCode = "backend.returnErrorCode" PropValidationRequestBody = "validation.requestBody" PropSecurityHeadersEnabled = "securityHeaders.enabled" PropSecurityHeadersSTSSeconds = "securityHeaders.stsSeconds" PropRouterHideVersionHeader = "router.hideVersionHeader" PropRouterTrustedProxies = "router.trustedProxies" PropRouterLoggerSkipPaths = "router.loggerSkipPaths" )
const TemplateId = "openapi-krakend-config"
TemplateId is the template id used to resolve --tpl-prop overrides (`-g krakend -t config`)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
SD string `json:"sd"`
Host []string `json:"host"`
URLPattern string `json:"url_pattern"`
Encoding string `json:"encoding"`
Method string `json:"method"`
DisableHostSanitize bool `json:"disable_host_sanitize"`
IsCollection bool `json:"is_collection,omitempty"`
Target string `json:"target,omitempty"`
ExtraConfig map[string]interface{} `json:"extra_config,omitempty"`
}
type BotDetectorConfig ¶
type CORSConfig ¶
type Config ¶ added in v0.3.0
type Config struct {
Environments []string
Port int
Timeout string
ReadTimeout string
WriteTimeout string
IdleTimeout string
ReadHeaderTimeout string
CacheTTL string
DebugEndpointEnvironments []string
EchoEndpointEnvironments []string
CORSEnabled bool
CORSAllowOrigins []string
BotDetectorEnabled bool
CircuitBreakerEnabled bool
LoggingLevel string
PrometheusPort int
OTLPHost string
OTLPPort int
TraceSampleRate float64
LoggingFormat string
GELFAddress string
ReturnErrorCode bool
ValidateRequestBody bool
SecurityHeadersEnabled bool
STSSeconds int
HideVersionHeader bool
TrustedProxies []string
LoggerSkipPaths []string
}
Config holds the generator settings that are not derived from the OpenAPI spec
func DefaultConfig ¶ added in v0.3.0
func DefaultConfig() Config
DefaultConfig returns the config built from the property defaults
type Endpoint ¶
type Endpoint struct {
Endpoint string `json:"endpoint"`
Method string `json:"method"`
OutputEncoding string `json:"output_encoding"`
Timeout string `json:"timeout,omitempty"`
CacheTTL string `json:"cache_ttl,omitempty"`
ConcurrentCalls int `json:"concurrent_calls,omitempty"`
Backend []Backend `json:"backend"`
InputQueryStrings []string `json:"input_query_strings,omitempty"`
InputHeaders []string `json:"input_headers,omitempty"`
ExtraConfig map[string]interface{} `json:"extra_config,omitempty"`
}
type ExtraConfig ¶
type ExtraConfig struct {
Router *RouterConfig `json:"router,omitempty"`
CORS *CORSConfig `json:"security/cors,omitempty"`
SecurityHTTP *SecurityHTTPConfig `json:"security/http,omitempty"`
BotDetector *BotDetectorConfig `json:"security/bot-detector,omitempty"`
Logging *LoggingConfig `json:"telemetry/logging,omitempty"`
Logstash *LogstashConfig `json:"telemetry/logstash,omitempty"`
GELF *GELFConfig `json:"telemetry/gelf,omitempty"`
OpenTelemetry *OpenTelemetryConfig `json:"telemetry/opentelemetry,omitempty"`
}
type GELFConfig ¶ added in v0.3.0
type GenerateKrakenConfigOpts ¶
type GenerateKrakenConfigOpts struct {
Config Config
Environment string
APIName string
BackendHost string // backend host including the scheme, e.g. https://api.example.com
BackendBasePath string
EndpointPrefix string // root x-krakend.endpoint_prefix
Auth map[string]interface{} // root x-krakend.auth, base auth/validator config for secured operations
ClientCredentials map[string]interface{} // root x-krakend.client_credentials, base auth/client-credentials config for backends
Operations map[string]OperationMeta // keyed by operationKey(method, path)
}
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
func NewGenerator ¶
func NewGenerator() *Generator
func (*Generator) Description ¶
func (*Generator) Generate ¶
func (g *Generator) Generate(opts openapigenerator.GenerateOpts) error
func (*Generator) IsPrimitiveType ¶
func (*Generator) PostProcessType ¶
func (g *Generator) PostProcessType(codeType openapigenerator.CodeType) openapigenerator.CodeType
func (*Generator) PostProcessing ¶
func (g *Generator) PostProcessing(files map[string]templateapi.RenderedFile) error
func (*Generator) TemplateData ¶
func (g *Generator) TemplateData(opts openapigenerator.TemplateDataOpts) (openapigenerator.DocumentModel, error)
func (*Generator) ToClassName ¶
func (*Generator) ToCodeType ¶
func (g *Generator) ToCodeType(schema *base.Schema, schemaType openapigenerator.CodeTypeSchemaType, required bool) (openapigenerator.CodeType, error)
func (*Generator) ToConstantName ¶
func (*Generator) ToFunctionName ¶
func (*Generator) ToParameterName ¶
func (*Generator) ToPropertyName ¶
func (*Generator) TypeToImport ¶
func (g *Generator) TypeToImport(iType openapigenerator.CodeType) string
type KrakenDConfig ¶
type KrakenDConfig struct {
Schema string `json:"$schema"`
Version int `json:"version"`
Name string `json:"name"`
ExtraConfig ExtraConfig `json:"extra_config"`
Timeout string `json:"timeout"`
ReadTimeout string `json:"read_timeout,omitempty"`
WriteTimeout string `json:"write_timeout,omitempty"`
IdleTimeout string `json:"idle_timeout,omitempty"`
ReadHeaderTimeout string `json:"read_header_timeout,omitempty"`
Port int `json:"port,omitempty"`
CacheTTL string `json:"cache_ttl,omitempty"`
DisableKeepAlives bool `json:"disable_keep_alives,omitempty"`
DisableCompression bool `json:"disable_compression,omitempty"`
MaxIdleConns int `json:"max_idle_connections,omitempty"`
MaxIdleConnsPerHost int `json:"max_idle_connections_per_host,omitempty"`
OutputEncoding string `json:"output_encoding"`
DebugEndpoint bool `json:"debug_endpoint"`
EchoEndpoint bool `json:"echo_endpoint"`
DisableRest bool `json:"disable_rest"`
Endpoints []Endpoint `json:"endpoints"`
}
type LoggingConfig ¶
type LogstashConfig ¶
type LogstashConfig struct {
Enabled bool `json:"enabled"`
}
type OTAttribute ¶ added in v0.3.0
type OTExporters ¶
type OTExporters struct {
Prometheus []PrometheusExporter `json:"prometheus,omitempty"`
OTLP []OTLPExporter `json:"otlp,omitempty"`
}
type OTLPExporter ¶
type OTLayerBackend ¶
type OTLayerBackend struct {
Metrics OTStageDetails `json:"metrics"`
Traces OTStageDetails `json:"traces"`
}
type OTLayerGlobal ¶
type OTLayerProxy ¶
type OTLayers ¶
type OTLayers struct {
Global OTLayerGlobal `json:"global"`
Proxy OTLayerProxy `json:"proxy"`
Backend OTLayerBackend `json:"backend"`
}
type OTStageDetails ¶
type OTStageDetails struct {
DisableStage bool `json:"disable_stage"`
RoundTrip bool `json:"round_trip"`
ReadPayload bool `json:"read_payload"`
DetailedConnection bool `json:"detailed_connection"`
StaticAttributes []OTAttribute `json:"static_attributes,omitempty"`
}
type OpenTelemetryConfig ¶
type OpenTelemetryConfig struct {
ServiceName string `json:"service_name,omitempty"`
TraceSampleRate float64 `json:"trace_sample_rate"`
MetricReportingPeriod int `json:"metric_reporting_period"`
Exporters OTExporters `json:"exporters"`
Layers OTLayers `json:"layers"`
}
type OperationMeta ¶ added in v0.3.0
type OperationMeta struct {
Servers openapigenerator.Endpoints // operation or path level servers
Security *OperationSecurity // nil if the operation is public
RequestBodySchema map[string]interface{} // inlined JSON schema of a required JSON request body
}
OperationMeta holds operation details that are not part of the generator-neutral template data
type OperationSecurity ¶ added in v0.3.0
type OperationSecurity struct {
ForwardHeaders []string // headers carrying credentials, e.g. Authorization or api key headers
ForwardQueryStrings []string // query strings carrying credentials
Bearer bool // a mandatory requirement uses a bearer token (oauth2, openIdConnect, http bearer)
Scopes []string // scopes of the first bearer requirement
TokenURL string // token url of the first oauth2 client credentials flow
}
type PrometheusExporter ¶
type ResolvedEndpoint ¶
type ResolvedEndpoint struct {
Host string // host including the scheme, e.g. https://api.example.com
BasePath string
RawURL string
Environment string
}
type RouterConfig ¶
type RouterConfig struct {
HideVersionHeader bool `json:"hide_version_header,omitempty"`
LoggerSkipPaths []string `json:"logger_skip_paths,omitempty"`
ForwardedByClientIP bool `json:"forwarded_by_client_ip,omitempty"`
RemoteIPHeaders []string `json:"remote_ip_headers,omitempty"`
TrustedProxies []string `json:"trusted_proxies,omitempty"`
}
type SecurityHTTPConfig ¶ added in v0.3.0
type SecurityHTTPConfig struct {
FrameDeny bool `json:"frame_deny,omitempty"`
ContentTypeNosniff bool `json:"content_type_nosniff,omitempty"`
BrowserXSSFilter bool `json:"browser_xss_filter,omitempty"`
ReferrerPolicy string `json:"referrer_policy,omitempty"`
STSSeconds int `json:"sts_seconds,omitempty"`
STSIncludeSubdomains bool `json:"sts_include_subdomains,omitempty"`
}