rest

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SERVER_TYPE is the type of the server.
	SERVER_TYPE = "rest"
)

Variables

View Source
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="`
}

Config manages the HTTP server config

func NewConfig

func NewConfig() *Config

NewConfig returns the parsed config for gateway server from env

func (*Config) Address

func (c *Config) Address() string

Address returns the full formatted http address

func (*Config) GetTags

func (c *Config) GetTags() []string

GetTags return the service registry tags slice

type Initializer

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

func NewInitializer

func NewInitializer(r *Rest) *Initializer

NewInitializer returns a new REST server 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

func (*Initializer) Run

func (i *Initializer) Run(ctx context.Context) error

Run start the service component

func (*Initializer) Stop

func (i *Initializer) Stop(ctx context.Context) error

Run start the service component

type Option

type Option func(*Rest)

Option to pass as arg while creating new service

func WithOptions

func WithOptions(opts ...fiber.Config) Option

WithMuxOptions adds mux options

type Rest

type Rest struct {
	App     *fiber.App
	Options []fiber.Config
	Server  *http.Server

	*Config
	// contains filtered or unexported fields
}

Rest server using gofiber

func NewRest

func NewRest(opts ...Option) *Rest

NewRest creates and returns rest server

func (*Rest) AddRegistryTags

func (r *Rest) AddRegistryTags(tags ...string)

AddRegistryTags - sets the registry tags for the server

func (*Rest) Address

func (r *Rest) Address() string

Address returns the server address

func (*Rest) GetMetadata

func (r *Rest) GetMetadata(key string) interface{}

GetMetadata returns the metadata by key

func (*Rest) HasInitializer

func (r *Rest) HasInitializer() bool

func (*Rest) Host

func (r *Rest) Host() string

Host returns gateway server hostname

func (*Rest) Initializer

func (r *Rest) Initializer() component.Initializer

func (*Rest) Port

func (r *Rest) Port() int

Port returns gateway server port

func (*Rest) RegistryTags

func (r *Rest) RegistryTags() []string

RegistryTags returns gateway server registry tags

func (*Rest) String

func (r *Rest) String() string

String - Returns the type of the server

Jump to

Keyboard shortcuts

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