web

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2018 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Null is /dev/null emulation

View Source
var (
	// ServersModule of web base structs
	ServersModule = module.Module{
		{Constructor: NewAPIServer},
		{Constructor: NewMetricsServer},
		{Constructor: NewPprofServer},
		{Constructor: NewMultiServer},
	}
)

Functions

func AddTagParsers added in v0.5.0

func AddTagParsers(parser tagParser)

AddTagParsers used in fieldName

func CheckErrors added in v0.5.0

func CheckErrors(opts ValidateParams) (ok bool, err error)

CheckErrors of validator and return formatted errors:

func NewBinder

func NewBinder(v Validator) echo.Binder

func NewEngine

func NewEngine(params EngineParams) *echo.Echo

func NewLogger

func NewLogger(log *zap.Logger) echo.Logger

func NewMultiServer added in v0.5.0

func NewMultiServer(params MultiServerParams) mserv.Server

NewMultiServer returns new multi servers group

Types

type APIParams added in v0.5.0

type APIParams struct {
	dig.In

	Config  *viper.Viper
	Logger  logger.StdLogger
	Handler http.Handler `optional:"true"`
}

type CustomError added in v0.4.1

type CustomError interface {
	FormatResponse(ctx echo.Context) error
}

type EmptyWriter

type EmptyWriter struct{}

EmptyWriter struct

func (EmptyWriter) Write

func (EmptyWriter) Write(data []byte) (int, error)

Write /dev/null emulation

type EngineParams added in v0.5.0

type EngineParams struct {
	dig.In

	Config     *viper.Viper   `optional:"true"`
	Binder     echo.Binder    `optional:"true"`
	Logger     *zap.Logger    `optional:"true"`
	EchoLogger echo.Logger    `optional:"true"`
	Validator  echo.Validator `optional:"true"`
}

type FieldError added in v0.5.0

type FieldError struct {
	Field     string
	Message   string
	Validator validator.FieldError
}

FieldError contains field name and validator error

func (FieldError) Error added in v0.5.0

func (f FieldError) Error() string

type FieldLevel added in v0.5.0

type FieldLevel = validator.FieldLevel

type Func added in v0.5.0

type Func = validator.Func

type MultiServerParams added in v0.5.0

type MultiServerParams struct {
	dig.In

	Logger  logger.StdLogger
	Servers []mserv.Server `group:"web_server"`
}

type ServerResult added in v0.5.0

type ServerResult struct {
	dig.Out

	Server mserv.Server `group:"web_server"`
}

func NewAPIServer added in v0.5.0

func NewAPIServer(v *viper.Viper, l logger.StdLogger, h http.Handler) ServerResult

NewAPIServerParams params for create api server by http.Handler from DI container

func NewMetricsServer added in v0.5.0

func NewMetricsServer(v *viper.Viper, l logger.StdLogger) ServerResult

NewMetricsServer returns wrapped prometheus http server

func NewPprofServer added in v0.5.0

func NewPprofServer(v *viper.Viper, l logger.StdLogger) ServerResult

NewPprofServer returns wrapped pprof http server

type ValidateParams added in v0.5.0

type ValidateParams struct {
	Struct    interface{}
	Errors    error
	Formatter func(fields []*FieldError) string
}

ValidateParams to call CheckErrors method

type Validator added in v0.5.0

type Validator interface {
	Validate(i interface{}) error
	Register(tag string, fn Func) error
}

func NewValidator added in v0.5.0

func NewValidator() Validator

func WrapValidator added in v0.5.0

func WrapValidator(v *validator.Validate) Validator

Jump to

Keyboard shortcuts

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