Configuration

Technical reference of Configuración.

This API is used in Configuration.


Symbols

SymbolClassDescription
ConfigtypeConfig defines a public type of API.
DevConfigtypeDevConfig defines a public type of API.
DevLogsConfigtypeDevLogsConfig defines a public type of API.
HTTPConfigtypeHTTPConfig defines a public type of API.
TLSConfigtypeHTTPS and certificates configuration.
DNSProviderinterfaceDNS record provider for ACME.
ResolverIPForwardedConfigtypeResolverIPForwardedConfig defines a public type of API.
RoutesConfigtypeRoutesConfig defines a public type of API.

Config

Declaration:

gox
type Config struct {
	ProjectName   string
	Dev           DevConfig
	UnmarshalText map[string]func(string) (any, error)
	Cluster       ClusterAdapter
	HTTP      HTTPConfig
	RateLimit RateLimitConfig
	Session   SessionConfig
	Static    StaticConfig
	Routes    RoutesConfig
	WebSocket WebSocketConfig
	OnStartServer func() error
	OnStopServer  func() error
}

Config defines a public type of API.

Fields

FieldTypeDescription
ProjectNamestringName of the element.
DevDevConfigPublic data associated with Dev.
UnmarshalTextmap[string]func(string) (any, error)Public data associated with UnmarshalText.
ClusterClusterAdapterPublic data associated with Cluster.
HTTPHTTPConfigPublic data associated with HTTP.
RateLimitRateLimitConfigConfigured limit.
SessionSessionConfigAssociated session.
StaticStaticConfigPublic data associated with Static.
RoutesRoutesConfigPublic data associated with Routes.
WebSocketWebSocketConfigPublic data associated with WebSocket.
OnStartServerfunc() errorPublic data associated with OnStartServer.
OnStopServerfunc() errorPublic data associated with OnStopServer.

DevConfig

Declaration:

gox
type DevConfig struct {
	Enabled bool
	Logs    DevLogsConfig
}

DevConfig defines a public type of API.

Fields

FieldTypeDescription
EnabledboolActivate or disable the function.
LogsDevLogsConfigPublic data associated with Logs.

DevLogsConfig

Declaration:

gox
type DevLogsConfig struct {
	Static    bool
	GoxFile   bool
	Trace     bool
	TraceDeep bool
}

DevLogsConfig defines a public type of API.

Fields

FieldTypeDescription
StaticboolPublic data associated with Static.
GoxFileboolAssociated file.
TraceboolPublic data associated with Trace.
TraceDeepboolPublic data associated with TraceDeep.

HTTPConfig

Declaration:

gox
type HTTPConfig struct {
	TLS                 TLSConfig
	Host                string
	Port                int
	MethodsAllowed      []string
	Compression         CompressionConfig
	ResolverIPForwarded ResolverIPForwardedConfig
}

HTTPConfig defines a public type of API.

Fields

FieldTypeDescription
TLSTLSConfigManual or automatic HTTPS configuration; see HTTP.
HoststringAddress where the server listens, no port.
PortintHTTP internal port; zero uses 3000.
MethodsAllowed[]stringAssociated method.
CompressionCompressionConfigPublic data associated with Compression.
ResolverIPForwardedResolverIPForwardedConfigPublic data associated with ResolverIPForwarded.

TLSConfig

Declaration:

gox
type TLSConfig struct {
    Enabled      bool
    Type         string
    Port         int
    Domains      []string
    Email        string
    CertFile     string
    KeyFile      string
    DNS          DNSProvider
    RedirectHTTP bool
}
FieldZero valueBehavior
EnabledfalseTLS disabled; your inactive options are ignored.
Type""It is equal to car. It supports car, http-01, tls-alpn-01, dns-01 and manual.
Port0Internal HTTPS port 443; other than HTTP port.
DomainsnilMandatory in automatic modes. Wildcard requires DNS.
Email""Optional ACME contact; not supported in manual.
CertFile""Required PEM string in manual; relative to project or absolute.
KeyFile""PEM key required in manual.
DNSnilSelect DNS-01 in car; mandatory in dns-01 and prohibited in other modes.
RedirectHTTPfalseIf true, redirect by 308 to public HTTPS 443. It does not prevent ACME challenges if it is false.

See the configuration examples in HTTPS and certificates.


DNSProvider

Declaration:

go
type DNSProvider interface {
    libdns.RecordAppender
    libdns.RecordDeleter
}

Compatible with libdns v1. The supplier must add and remove the validation TXT records, preserve other records, admit competing challenges and respect the cancellation of the context. A typed but nil supplier is rejected.


ResolverIPForwardedConfig

Declaration:

gox
type ResolverIPForwardedConfig struct {
	TrustedProxies      []string
	Headers             []string
	RequireTrustedProxy bool
}

ResolverIPForwardedConfig defines a public type of API.

Fields

FieldTypeDescription
TrustedProxies[]stringIPs / CIDR of reliable proxies to solve IP and accept X-Forwarded-Proto.
Headers[]stringIP headers, in order; does not control X-Forwarded-Proto.
RequireTrustedProxyboolIt requires applications for application to come from a reliable proxy if true.

RoutesConfig

Declaration:

gox
type RoutesConfig struct {
	Routes map[string]string
}

RoutesConfig defines a public type of API.

Fields

FieldTypeDescription
Routesmap[string]stringPublic data associated with Routes.

See also

Next step

Continue with static file configuration.

Static files