http

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface {
	config.TLS

	// Addr returns that network address the server listens to.
	Addr() string
}

Config contains the information necessary to create an HTTP server

type Option

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

Option provides options for configuring the creation of a http server.

func WithLogger

func WithLogger(l log.Logger) Option

WithLogger will add logging to the http server.

func WithTLS

func WithTLS(cfg *tls.Config) Option

WithTLS will configure the server to require TLS.

type Server

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

func New

func New(cfg Config, opts ...Option) (*Server, error)

New creates an HTTP server with a default handler and has not started to accept requests yet.

func (*Server) Handle

func (s *Server) Handle(mux http.Handler)

Handle associates the given handler with the server.

func (*Server) Serve

func (s *Server) Serve(result chan<- error)

Serve accepts incoming connections, creating a new service goroutine for each. The service goroutine reads requests and then call the handler to reply to them.

func (*Server) Stop

func (s *Server) Stop()

Stop shuts down the http server gracefully without interrupting an active connections.

Directories

Path Synopsis
Package mockhttp is a generated GoMock package.
Package mockhttp is a generated GoMock package.

Jump to

Keyboard shortcuts

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