server

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger() gin.HandlerFunc

Logger is logger middleware

func Recovery

func Recovery() gin.HandlerFunc

Recovery returns a middleware that recovers from any panics and writes a 500 if there was one.

func Trace

func Trace() gin.HandlerFunc

Trace is trace middleware

Types

type Server

type Server struct {
	*http.Server
	*gin.Engine
	// contains filtered or unexported fields
}

func DefaultServer

func DefaultServer(conf *ServerConfig) *Server

DefaultServer returns an Engine instance with the Recovery and Logger middleware already attached.

func NewServer

func NewServer(conf *ServerConfig) *Server

NewServer returns a new blank Engine instance without any middleware attached.

func (*Server) RunServer

func (engine *Server) RunServer(server *http.Server, l net.Listener) (err error)

RunServer will serve and start listening HTTP requests by given server and listener. Note: this method will block the calling goroutine indefinitely unless an error happens.

func (*Server) Shutdown

func (engine *Server) Shutdown(ctx context.Context) error

Shutdown the http server without interrupting active connections.

func (*Server) Start

func (engine *Server) Start() error

Start listen and serve bm engine by given DSN.

type ServerConfig

type ServerConfig struct {
	Network      string        `dsn:"network"`
	Addr         string        `dsn:"address"`
	Timeout      time.Duration `dsn:"query.timeout"`
	ReadTimeout  time.Duration `dsn:"query.readTimeout"`
	WriteTimeout time.Duration `dsn:"query.writeTimeout"`
}

ServerConfig is the bm server config model

Jump to

Keyboard shortcuts

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