Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type Gateway
- func (g *Gateway) AddRegistryTags(tags ...string)
- func (g *Gateway) Address() string
- func (g *Gateway) GetMetadata(key string) interface{}
- func (g *Gateway) HasInitializer() bool
- func (g *Gateway) Host() string
- func (g *Gateway) Initializer() component.Initializer
- func (g *Gateway) Port() int
- func (g *Gateway) RegistryTags() []string
- func (g *Gateway) String() string
- type HTTPServiceHandlerRegistrar
- type Initializer
- type Metadata
- type Middleware
- type Option
Constants ¶
const (
// SERVER_TYPE is the type of the server.
SERVER_TYPE = "gateway"
)
Variables ¶
var ( // ErrGatewayConfigLoad returned when env config for gRPC-gateway results in an error ErrGatewayConfigLoad = errors.New("error loading gateway config") // ErrNotDefinedHTTPServiceHandlerRegistrar thrown when http service registration handler is not provided ErrNotDefinedHTTPServiceHandlerRegistrar = errors.New("http service handler registration callback not provided") // ErrHTTPServiceHandlerRegFailed returned when any HTTP service handler registration fails ErrHTTPServiceHandlerRegFailed = errors.New("http service handler registration failed") // ErrCannotAddMuxOptionAtPos returned when adding new mux option at the specified position is not possible ErrCannotAddMuxOptionAtPos = errors.New("cannot add mux option at the position specified") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Host string `env:"HTTP_HOST,defaut="` Port int `env:"HTTP_PORT,default=8080"` Tags string `env:"HTTP_CONSUL_TAGS,default="` Metadata Metadata }
Config manages the HTTP server config
func NewConfig ¶
func NewConfig() *Config
NewConfig returns the parsed config for gateway server from env
type Gateway ¶
type Gateway struct { Mux *runtime.ServeMux Middleware []Middleware HTTPServiceHandlerRegistrar HTTPServiceHandlerRegistrar MuxOptions []runtime.ServeMuxOption Server *http.Server *Config // contains filtered or unexported fields }
Gateway handle gRPC gateway
func NewGateway ¶
NewGateway creates and returns gRPC-gateway
func (*Gateway) AddRegistryTags ¶
AddRegistryTags - sets the registry tags for the server
func (*Gateway) GetMetadata ¶
GetMetadata returns the metadata by key
func (*Gateway) HasInitializer ¶
func (*Gateway) Initializer ¶
func (g *Gateway) Initializer() component.Initializer
func (*Gateway) RegistryTags ¶
RegistryTags returns gateway server registry tags
type HTTPServiceHandlerRegistrar ¶
HTTPServiceHandlerRegistrar HTTP service handler registration func
type Initializer ¶
type Initializer struct {
// contains filtered or unexported fields
}
func NewInitializer ¶
func NewInitializer(g *Gateway) *Initializer
NewInitializer returns a new JetStream Initialiazer
func (*Initializer) AddDependency ¶
func (i *Initializer) AddDependency(dep interface{}) error
AddDependency adds necessary service components as dependencies
func (*Initializer) CanRun ¶
func (i *Initializer) CanRun() bool
CanRun returns true if the component has anything to Run
func (*Initializer) CanStop ¶
func (i *Initializer) CanStop() bool
CanRun returns true if the component has anything to Run
func (*Initializer) Dependencies ¶
func (i *Initializer) Dependencies() []string
Dependencies returns the string names of service components that are required as dependencies for this component
type Metadata ¶
type Metadata struct { GrpcHost string `env:"GRPC_HOST,default="` GrpcPort int `env:"GRPC_PORT,default=9090"` }
Metadata holds the metadata used by the gateway server
type Option ¶
type Option func(*Gateway)
Option to pass as arg while creating new service
func WithHTTPServiceHandlerRegistrar ¶
func WithHTTPServiceHandlerRegistrar(registrar HTTPServiceHandlerRegistrar) Option
WithHTTPServiceHandlerRegistrar add HTTP service handle registration callback
func WithMiddleware ¶
func WithMiddleware(middleware ...Middleware) Option
WithMiddleware adds middleware to the rest handler
func WithMuxOptions ¶
func WithMuxOptions(opts ...runtime.ServeMuxOption) Option
WithMuxOptions adds mux options