Documentation
¶
Overview ¶
Package gateway is GTB's framework-integration layer over the extracted grpc-gateway module.
The pure gateway construction now lives in gitlab.com/phpboyscout/go/transport/gateway; this package binds it to the GTB config store. It provides the config-driven adapters — SettingsFromConfig, ObserveSettingsFromConfig, NewFromConfig, RegisterFromConfig — which resolve the gateway's HTTP settings and the upstream gRPC endpoint from config, dial the local gRPC server, and delegate to the transport constructors. The adapter owns its own Option set (WithDialOptions, WithMuxOptions, WithMiddleware) because it, not the transport, performs the config-driven dial.
Code that already has a *grpc.ClientConn imports go/transport/gateway directly.
Index ¶
- Constants
- func NewFromConfig(ctx context.Context, cfg config.Reader, register RegisterFunc, opts ...Option) (http.Handler, error)
- func ObserveSettingsFromConfig(cfg config.Binder, ...) (*config.ObservedSection[transportgateway.Settings], error)
- func RegisterFromConfig(ctx context.Context, id string, controller controls.Controllable, ...) (*http.Server, error)
- func SettingsFromConfig(cfg config.Reader) transportgateway.Settings
- type Option
- type RegisterFunc
Constants ¶
const ConfigPrefix = "server.gateway"
ConfigPrefix is the config block a gateway server reads (its HTTP listener port and TLS) when run as its own service via Register. TLS falls back to the shared "server.tls".
Variables ¶
This section is empty.
Functions ¶
func NewFromConfig ¶ added in v0.30.0
func NewFromConfig(ctx context.Context, cfg config.Reader, register RegisterFunc, opts ...Option) (http.Handler, error)
NewFromConfig builds a grpc-gateway handler with GTB config resolved into typed transport settings before delegating to the config-free constructor.
func ObserveSettingsFromConfig ¶ added in v0.30.0
func ObserveSettingsFromConfig( cfg config.Binder, opts ...config.SectionBindingOption[transportgateway.Settings], ) (*config.ObservedSection[transportgateway.Settings], error)
ObserveSettingsFromConfig binds gateway transport settings to cfg and keeps a typed snapshot rehydrated after successful config reloads.
func RegisterFromConfig ¶ added in v0.30.0
func RegisterFromConfig(ctx context.Context, id string, controller controls.Controllable, cfg config.Reader, log logger.Logger, register RegisterFunc, opts ...Option) (*http.Server, error)
RegisterFromConfig runs the gateway with GTB config resolved into typed transport settings before delegating to the config-free constructor.
func SettingsFromConfig ¶ added in v0.30.0
func SettingsFromConfig(cfg config.Reader) transportgateway.Settings
SettingsFromConfig resolves gateway transport settings from GTB config. The managed HTTP server reads server.gateway.* while the in-process gRPC dial uses server.grpc.* so it connects to the same local gRPC service as the rest of GTB.
Types ¶
type Option ¶
type Option func(*options)
Option configures a GTB gateway adapter: the in-process gRPC dial options, the grpc-gateway mux options, and an optional middleware chain over the REST surface. GTB owns this option type because it, not the transport, performs the config-driven dial.
func WithDialOptions ¶
func WithDialOptions(opts ...grpc.DialOption) Option
WithDialOptions passes extra grpc.DialOption values to the in-process connection the gateway dials to the local gRPC server.
func WithMiddleware ¶ added in v0.23.0
func WithMiddleware(chain transithttp.Chain) Option
WithMiddleware wraps the gateway's REST surface with a middleware chain (health endpoints, when run via Register, stay outside it).
func WithMuxOptions ¶
func WithMuxOptions(opts ...runtime.ServeMuxOption) Option
WithMuxOptions passes grpc-gateway runtime.ServeMuxOption values to the mux.
type RegisterFunc ¶
type RegisterFunc = transportgateway.RegisterFunc
RegisterFunc registers the generated gateway handlers onto the mux. It is re-exported from the transport gateway so call sites keep a single type.