gateway

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HeaderMatcherFunc

type HeaderMatcherFunc = func(string) (string, bool)

HeaderMatcherFunc is a function for matching headers in gRPC gateway

type JSONConfig

type JSONConfig struct {
	// UseProtoNames determines if proto or json names should be used
	UseProtoNames bool `envconfig:"USE_PROTO_NAMES" default:"true"`
	// EmitUnpopulated determines if unpopulated fields should be included
	EmitUnpopulated bool `envconfig:"EMIT_UNPOPULATED" default:"true"`
	// UseEnumNumbers renders enum values as numbers instead of strings
	UseEnumNumbers bool `envconfig:"USE_ENUM_NUMBERS" default:"true"`
	// AllowPartial allows incomplete proto messages
	AllowPartial bool `envconfig:"ALLOW_PARTIAL" default:"true"`
	// Multiline formats the output in indented form
	Multiline bool `envconfig:"MULTILINE" default:"true"`
	// Indent specifies the set of indentation characters to use in multiline mode
	Indent string `envconfig:"INDENT" default:"  "`
}

JSONConfig holds JSON marshaling configuration for the gateway

func DefaultJSONConfig

func DefaultJSONConfig() *JSONConfig

DefaultJSONConfig returns a JSONConfig with default values

type Option

type Option func(*Server)

Option is a function that configures a Server

func WithCORS

func WithCORS(options *cors.Options) Option

WithCORS enables CORS support

func WithIncomingHeaderMatcher

func WithIncomingHeaderMatcher(matcher HeaderMatcherFunc) Option

WithIncomingHeaderMatcher sets the incoming header matcher function

func WithJSONConfig

func WithJSONConfig(config *JSONConfig) Option

WithJSONConfig sets the JSON configuration for the gateway

func WithMuxOptions

func WithMuxOptions(options ...runtime.ServeMuxOption) Option

WithMuxOptions sets the gRPC-Gateway mux options

func WithOutgoingHeaderMatcher

func WithOutgoingHeaderMatcher(matcher HeaderMatcherFunc) Option

WithOutgoingHeaderMatcher sets the outgoing header matcher function

func WithPprof

func WithPprof(enabled bool) Option

WithPprof enables the pprof profiler

func WithServices

func WithServices(registrars ...service.Registrar) Option

WithServices sets the service registrars for the gateway

func WithSwagger

func WithSwagger(dir, basePath string) Option

WithSwagger enables Swagger UI

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represents a gRPC-Gateway server

func NewServer

func NewServer(
	logger *slog.Logger,
	closeTimeout time.Duration,
	grpcAddress string,
	httpAddress string,
	opts ...Option,
) *Server

NewServer creates a new gRPC-Gateway server

func (*Server) PreRun

func (*Server) PreRun(_ context.Context) error

PreRun prepares the gateway server

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the gRPC-Gateway server

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully stops the gRPC-Gateway server

Jump to

Keyboard shortcuts

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