http

package
v0.0.0-...-0cd5192 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Message    string `json:"message"`
	StatusCode int    `json:"-"`
	Err        error  `json:"-"`
}

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

type APIResponse

type APIResponse struct {
	Data       interface{} `json:"data,omitempty"`
	Error      *APIError   `json:"error,omitempty"`
	StatusCode int         `json:"-"`
}

type Server

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

Server represents a server for HTTP and TLS.

func NewServer

func NewServer(opts ...ServerOption) *Server

func (*Server) CaptureRequest

func (srv *Server) CaptureRequest(w http.ResponseWriter, r *http.Request)

func (*Server) CreateHosts

func (srv *Server) CreateHosts(w http.ResponseWriter, r *http.Request)

func (*Server) GetHostByID

func (srv *Server) GetHostByID(w http.ResponseWriter, r *http.Request)

func (*Server) Handler

func (srv *Server) Handler() http.Handler

func (*Server) ListHTTPLogEntries

func (srv *Server) ListHTTPLogEntries(w http.ResponseWriter, r *http.Request)

func (*Server) RecoveryMiddleware

func (srv *Server) RecoveryMiddleware(h http.Handler) http.Handler

func (*Server) Run

func (srv *Server) Run(ctx context.Context) error

Run starts the HTTP and (if enabled) HTTPS server.

func (*Server) Shutdown

func (srv *Server) Shutdown(ctx context.Context) error

type ServerOption

type ServerOption func(*Server)

func WithACMEManager

func WithACMEManager(am *certmagic.ACMEManager) ServerOption

WithACMEManager overrides the ACME manager used. If you call this function with `nil`, it will disable ACME support.

func WithHTTPAddr

func WithHTTPAddr(addr string) ServerOption

WithHTTPAddr overrides the default TCP address for the HTTP server to listen on.

func WithHostname

func WithHostname(hostname string) ServerOption

WithHostname sets the hostname used to serve the API.

func WithHostsService

func WithHostsService(svc hosts.Service) ServerOption

WithHostsService sets the hosts.Service used for managing hosts, e.g. creating new hosts and capturing network traffic received on them.

func WithLogger

func WithLogger(logger *zap.Logger) ServerOption

WithLogger provides a logger, which is used for HTTP related logs.

func WithTLSAddr

func WithTLSAddr(addr string) ServerOption

WithTLSAddr overrides the default TCP address for the HTTPS server to listen on.

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config) ServerOption

WithTLSConfig overrides the TLS config used.

func WithoutTLS

func WithoutTLS() ServerOption

WithoutTLS disables binding on a port for serving TLS. This will implicitly disable the TLS-ALPN challenge of the ACME protocol.

Jump to

Keyboard shortcuts

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