http

package
v0.0.0-...-a6d44c8 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Version = "0.0.1"
)

Variables

This section is empty.

Functions

func DecodeRequest

func DecodeRequest(r *http.Request, contentType string, v interface{}) (err error)

func EncodeResponse

func EncodeResponse(w http.ResponseWriter, contentType string, v proto.Message) (err error)

func GenerateAwesomeData

func GenerateAwesomeData(r *http.Request, log *logrus.Entry) (logger *logrus.Entry, ctx context.Context)

func HealthCheck

func HealthCheck(next http.Handler) http.Handler

func Limit

func Limit(next http.Handler) http.Handler

func Recovery

func Recovery(next http.Handler) http.Handler

func Timeout

func Timeout(next http.Handler) http.Handler

Types

type Server

type Server struct {
	*http.Server
	Logger *logrus.Entry
	// contains filtered or unexported fields
}

func NewServer

func NewServer(app string, opts ...ServerOption) *Server

func (*Server) Run

func (s *Server) Run() error

func (*Server) SetHandler

func (s *Server) SetHandler(handler http.Handler)

func (*Server) Stop

func (s *Server) Stop() error

Stop stop the http server.

type ServerOption

type ServerOption func(o *Server)

func Address

func Address(addr string) ServerOption

Address with server address.

func Logger

func Logger(logger *logrus.Entry) ServerOption

func Prometheus

func Prometheus(enableHandlingTimeHistogram bool) ServerOption

func ReadTimeout

func ReadTimeout(timeout time.Duration) ServerOption

Timeout with server timeout.

Jump to

Keyboard shortcuts

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