http

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option overrides behavior of Server.

func WithEnableH2C

func WithEnableH2C(enableH2C bool) Option

func WithGracePeriod

func WithGracePeriod(t time.Duration) Option

WithGracePeriod sets shutdown grace period for HTTP server. Server waits connections to drain for specified amount of time.

func WithListen

func WithListen(s string) Option

WithListen sets address to listen for HTTP server. Server accepts incoming TCP connections on given address.

func WithMux

func WithMux(mux *http.ServeMux) Option

WithMux overrides the the server's default mux.

func WithTLSConfig

func WithTLSConfig(tls string) Option

type ResponseWriterWithStatus

type ResponseWriterWithStatus struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

ResponseWriterWithStatus wraps around http.ResponseWriter to capture the status code of the response.

func WrapResponseWriterWithStatus

func WrapResponseWriterWithStatus(w http.ResponseWriter) *ResponseWriterWithStatus

WrapResponseWriterWithStatus wraps the http.ResponseWriter for extracting status.

func (*ResponseWriterWithStatus) Status

func (r *ResponseWriterWithStatus) Status() int

Status returns http response status.

func (*ResponseWriterWithStatus) WriteHeader

func (r *ResponseWriterWithStatus) WriteHeader(code int)

WriteHeader writes the header.

type Server

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

A Server defines parameters for serve HTTP requests, a wrapper around http.Server.

func New

func New(logger log.Logger, reg *prometheus.Registry, comp component.Component, prober *prober.HTTPProbe, opts ...Option) *Server

New creates a new Server.

func (*Server) Handle

func (s *Server) Handle(pattern string, handler http.Handler)

Handle registers the handler for the given pattern.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe listens on the TCP network address and handles requests on incoming connections.

func (*Server) Shutdown

func (s *Server) Shutdown(err error)

Shutdown gracefully shuts down the server by waiting, for specified amount of time (by gracePeriod) for connections to return to idle and then shut down.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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