http

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DurationSeconds = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "handling_seconds",
			Help:      "The invocation duration in seconds.",
		},
		[]string{
			"request_uri",
		},
	)

	RequestsTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "handled_total",
			Help:      "The number of requests.",
		},
		[]string{
			"request_uri",
			"http_method",
			"http_status",
		},
	)

	RequestsBytesTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "requests_received_bytes",
			Help:      "A summary of the invocation requests bytes.",
		},
		[]string{
			"request_uri",
			"http_method",
		},
	)

	ResponsesBytesTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "responses_sent_bytes",
			Help:      "A summary of the invocation responses bytes.",
		},
		[]string{
			"request_uri",
			"http_method",
		},
	)
)

Functions

func NewJSONMessage

func NewJSONMessage(msgMap map[string]interface{}) ([]byte, error)

func RecordMetrics

func RecordMetrics(start time.Time, status int, writer http.ResponseWriter, request *http.Request)

func WriteResponse

func WriteResponse(w http.ResponseWriter, content []byte, status int, logger *zap.Logger)

Types

type Router added in v0.6.0

type Router struct {
	mux.Router

	GRPCClient *grpc.Client
	// contains filtered or unexported fields
}

func NewRouter added in v0.6.0

func NewRouter(grpcAddr string, logger *zap.Logger) (*Router, error)

func (*Router) Close added in v0.6.0

func (r *Router) Close() error

type Server added in v0.6.0

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

func NewServer added in v0.6.0

func NewServer(httpAddr string, router *Router, logger *zap.Logger, httpLogger accesslog.Logger) (*Server, error)

func (*Server) Start added in v0.6.0

func (s *Server) Start() error

func (*Server) Stop added in v0.6.0

func (s *Server) Stop() error

Jump to

Keyboard shortcuts

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