server

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ListenAddrFlagName = "addr"
	PortFlagName       = "port"
)
View Source
const (
	GetRoute = "/get/"
	PutRoute = "/put/"

	DomainFilterKey = "domain"
)
View Source
const EnvVarPrefix = "EIGENDA_PROXY"

Variables

View Source
var (
	ListenAddrFlag = &cli.StringFlag{
		Name:    ListenAddrFlagName,
		Usage:   "server listening address",
		Value:   "127.0.0.1",
		EnvVars: prefixEnvVars("ADDR"),
	}
	PortFlag = &cli.IntFlag{
		Name:    PortFlagName,
		Usage:   "server listening port",
		Value:   3100,
		EnvVars: prefixEnvVars("PORT"),
	}
)
View Source
var (
	ErrNotFound = errors.New("not found")
)
View Source
var Flags []cli.Flag

Flags contains the list of configuration options available to the binary.

Functions

func CheckRequired

func CheckRequired(ctx *cli.Context) error

func LoadStore

func LoadStore(cfg CLIConfig, ctx context.Context, log log.Logger) (store.Store, error)

func ReadDomainFilter

func ReadDomainFilter(r *http.Request) (common.DomainType, error)

func WithLogging

func WithLogging(handleFn func(http.ResponseWriter, *http.Request) error, log log.Logger) func(http.ResponseWriter, *http.Request)

func WithMetrics

func WithMetrics(handleFn func(http.ResponseWriter, *http.Request) error, m metrics.Metricer) func(http.ResponseWriter, *http.Request) error

WithMetrics is a middleware that records metrics for the route path.

Types

type CLIConfig

type CLIConfig struct {
	MemStoreCfg   store.MemStoreConfig
	EigenDAConfig eigenda.Config
	MetricsCfg    opmetrics.CLIConfig
}

func ReadCLIConfig

func ReadCLIConfig(ctx *cli.Context) CLIConfig

func (CLIConfig) Check

func (c CLIConfig) Check() error

type Server

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

func NewServer

func NewServer(host string, port int, store store.Store, log log.Logger, m metrics.Metricer) *Server

func (*Server) Endpoint

func (svr *Server) Endpoint() string

func (*Server) HandleGet

func (svr *Server) HandleGet(w http.ResponseWriter, r *http.Request) error

func (*Server) HandlePut

func (svr *Server) HandlePut(w http.ResponseWriter, r *http.Request) error

func (*Server) Health

func (svr *Server) Health(w http.ResponseWriter, r *http.Request) error

func (*Server) Port added in v1.1.1

func (svr *Server) Port() int

func (*Server) Start

func (svr *Server) Start() error

func (*Server) Stop

func (svr *Server) Stop() error

func (*Server) Store added in v1.1.1

func (svr *Server) Store() store.Store

func (*Server) WriteBadRequest

func (svr *Server) WriteBadRequest(w http.ResponseWriter, msg string)

func (*Server) WriteInternalError

func (svr *Server) WriteInternalError(w http.ResponseWriter, err error)

func (*Server) WriteNotFound

func (svr *Server) WriteNotFound(w http.ResponseWriter, msg string)

func (*Server) WriteResponse

func (svr *Server) WriteResponse(w http.ResponseWriter, data []byte)

Jump to

Keyboard shortcuts

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