Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaybeCloseConnection ¶
func MaybeCloseConnection(w http.ResponseWriter, r *http.Request)
func NewClient ¶
func NewClient(opts ClientOpts) *http.Client
Types ¶
type ClientOpts ¶
type ClientOpts struct { // Close controls whether the client closes the connection after each request. Close bool // Timeout is the timeout for the http client and the http request. Timeout time.Duration // InsecureSkipVerify controls whether the client verifies the server's certificate chain and host name. InsecureSkipVerify bool // IdleConnTimeout is the maximum amount of time an idle (keep-alive) connection // will remain idle before closing itself. IdleConnTimeout time.Duration // ResponseHeaderTimeout is the amount of time to wait for a server's response headers // after fully writing the request (including its body, if any). ResponseHeaderTimeout time.Duration // MaxIdleConns controls the maximum number of idle (keep-alive) connections across all hosts. MaxIdleConns int // MaxIdleConnsPerHost, if non-zero, controls the maximum idle (keep-alive) per host. MaxIdleConnsPerHost int // MaxConnsPerHost, if non-zero, controls the maximum connections per host. MaxConnsPerHost int // TLSHandshakeTimeout specifies the maximum amount of time to // wait for a TLS handshake. Zero means no timeout. TLSHandshakeTimeout time.Duration // DisableHTTP2 controls whether the client disables HTTP/2 support. DisableHTTP2 bool // DisableKeepAlives controls whether the client disables HTTP keep-alives. DisableKeepAlives bool }
func (ClientOpts) WithDefaults ¶
func (c ClientOpts) WithDefaults() ClientOpts
type HttpHandler ¶
type HttpHandler struct { Path string Handler http.HandlerFunc }
type HttpServer ¶
type HttpServer struct {
// contains filtered or unexported fields
}
HttpServer is a http server that is preconfigured with a prometheus metrics handler. Additional handlers can be registered with RegisterHandler.
func NewServer ¶
func NewServer(opts *ServerOpts) *HttpServer
func (*HttpServer) Open ¶
func (s *HttpServer) Open(ctx context.Context) error
Open starts the http server.
func (*HttpServer) RegisterHandler ¶
func (s *HttpServer) RegisterHandler(path string, handler http.Handler)
RegisterHandler registers a new handler at the given path. The handler must be registered before Open is called.
func (*HttpServer) RegisterHandlerFunc ¶
func (s *HttpServer) RegisterHandlerFunc(path string, handlerFunc http.HandlerFunc)
RegisterHandlerFunc registers a new handler at the given path. The handler must be registered before Open is called.
func (*HttpServer) String ¶
func (s *HttpServer) String() string
type ServerOpts ¶
type ServerOpts struct { // MaxConns is the maximum number of connections the server will accept. This value is only respected if // Listener is nil. MaxConns int // ReadTimeout is the maximum duration before timing out read of the request. // If not specified, the default is 5 seconds. ReadTimeout time.Duration // WriteTimeout is the maximum duration before timing out write of the response. // If not specified, the default is 10 seconds. WriteTimeout time.Duration // IdleTimeout is the maximum amount of time to wait for the next request when keep-alives are enabled. // If not specified, the default is 10 seconds. IdleTimeout time.Duration // MaxHeaderBytes is the maximum number of bytes the server will read parsing the request header's keys and values, // If not specified, the default is 1MB (1 << 20). MaxHeaderBytes int // ListenAddr is the address to listen on. If a Listener is provided, this value is ignored. ListenAddr string // Listener is the listener to use. If nil, a new listener will be created. Listener net.Listener }
Click to show internal directories.
Click to hide internal directories.