server

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOn  = 1
	StatusOff = 0
)

Variables

View Source
var (
	//ErrServAlreadyRunning error than run method UP if server already started
	ErrServAlreadyRunning = errors.New("server already running")
	//ErrServAlreadyStopped error than run method Down if server already stopped
	ErrServAlreadyStopped = errors.New("server already stopped")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	HTTP ConfigItem `yaml:"http" json:"http"`
}

Config model

func (Config) MarshalEasyJSON

func (v Config) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Config) MarshalJSON

func (v Config) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Config) UnmarshalEasyJSON

func (v *Config) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Config) UnmarshalJSON

func (v *Config) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ConfigItem

type ConfigItem struct {
	Addr            string        `yaml:"addr" json:"addr"`
	ReadTimeout     time.Duration `yaml:"read_timeout" json:"read_timeout"`
	WriteTimeout    time.Duration `yaml:"write_timeout" json:"write_timeout"`
	IdleTimeout     time.Duration `yaml:"idle_timeout" json:"idle_timeout"`
	ShutdownTimeout time.Duration `yaml:"shutdown_timeout" json:"shutdown_timeout"`
}

ConfigItem model

func (ConfigItem) MarshalEasyJSON

func (v ConfigItem) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ConfigItem) MarshalJSON

func (v ConfigItem) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ConfigItem) UnmarshalEasyJSON

func (v *ConfigItem) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ConfigItem) UnmarshalJSON

func (v *ConfigItem) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Server

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

Server ...

func New

func New(config *Config, router *routes.Router, log logger.Logger) *Server

New create default http server

func NewCustom

func NewCustom(conf ConfigItem, handler http.Handler, log logger.Logger) *Server

NewCustom create custom http server

func (*Server) Down

func (s *Server) Down() error

Down stop http server

func (*Server) Up

func (s *Server) Up() error

Up start http server

Jump to

Keyboard shortcuts

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