server

package
v1.9.6 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxLimit      = 1000
	DefaultLimit  = 100
	DefaultOffset = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Port      int
	Fullname  string
	ClusterID string
	Http      fiber.Config
}

Config for HTTP server

func (Config) Addr

func (c Config) Addr() string

Addr returns port based address

type HTTPServer

type HTTPServer struct {
	Mux    *fiber.App
	Log    *zap.SugaredLogger
	Routes fiber.Router
	Config Config
}

HTTPServer represents basic REST HTTP server abstarction

func NewServer

func NewServer(config Config) HTTPServer

NewServer returns new HTTP server instance, initializes logger and metrics

func (*HTTPServer) Error

func (s *HTTPServer) Error(c *fiber.Ctx, status int, err error, context ...interface{}) error

Error writes RFC-7807 json problem to response

func (HTTPServer) GetPager

func (s HTTPServer) GetPager(c *fiber.Ctx) Pager

GetPager returns new configured Pager instance

func (HTTPServer) HealthEndpoint

func (s HTTPServer) HealthEndpoint() fiber.Handler

HealthEndpoint for health checks

func (*HTTPServer) Init

func (s *HTTPServer) Init()

Init initializes router and setting up basic routes for health and metrics

func (*HTTPServer) Run

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

Run starts listening for incoming connetions

func (*HTTPServer) Warn added in v0.7.19

func (s *HTTPServer) Warn(c *fiber.Ctx, status int, err error, context ...interface{}) error

Warn writes RFC-7807 json problem to response

type Pager

type Pager struct {
	Limit  int
	Offset int
	NextID string
}

Pager is abstracion to handle data grid like data paging

Jump to

Keyboard shortcuts

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