pomerium/config/runtime_flags.go
Caleb Doxsey 5373e25ac4
core/config: add support for stripping the port for matching routes (#5085)
* core/config: add support for stripping the port for matching routes

* fix test

* rename option, improve port detection

* add more test cases
2024-04-26 08:24:46 -06:00

29 lines
841 B
Go

package config
import "golang.org/x/exp/maps"
var (
// RuntimeFlagGRPCDatabrokerKeepalive enables gRPC keepalive to the databroker service
RuntimeFlagGRPCDatabrokerKeepalive = runtimeFlag("grpc_databroker_keepalive", false)
// RuntimeFlagMatchAnyIncomingPort enables ignoring the incoming port when matching routes
RuntimeFlagMatchAnyIncomingPort = runtimeFlag("match_any_incoming_port", true)
)
// RuntimeFlag is a runtime flag that can flip on/off certain features
type RuntimeFlag string
// RuntimeFlags is a map of runtime flags
type RuntimeFlags map[RuntimeFlag]bool
func runtimeFlag(txt string, def bool) RuntimeFlag {
key := RuntimeFlag(txt)
defaultRuntimeFlags[key] = def
return key
}
var defaultRuntimeFlags = map[RuntimeFlag]bool{}
func DefaultRuntimeFlags() RuntimeFlags {
return maps.Clone(defaultRuntimeFlags)
}