http

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HeaderFromStringSlice

func HeaderFromStringSlice(s []string) (http.Header, error)

Types

type Middleware

type Middleware func(http.HandlerFunc) http.HandlerFunc

func BasicAuthMiddleware

func BasicAuthMiddleware(unauthenticated http.HandlerFunc, username, password string) (Middleware, string, error)

func BlockPrefetch

func BlockPrefetch(userAgentKeys ...string) Middleware

BlockPrefetch blocks prefetching of the page by reloading the page with a short-lived cookie that's only set if the page is visible. This is to prevent browsers and bots from prefetching. Some have recently started not marking the request as a prefetch, so this is a last resort.

func BotsMiddleware

func BotsMiddleware(block bool) Middleware

func LimitReaderMiddleware

func LimitReaderMiddleware(limit int64) Middleware

func MiddlewareShim

func MiddlewareShim(mw func(http.Handler) http.Handler) Middleware

func (Middleware) Chain

func (mw Middleware) Chain(m Middleware) Middleware

type ResponseWriter

type ResponseWriter interface {
	http.ResponseWriter
	IgnoreOutcome()
}

type Server

type Server struct {
	PreSuccessHandler  http.HandlerFunc
	PostSuccessHandler http.HandlerFunc

	TLSCert, TLSKey string
	Timeout         time.Duration

	ExitOnFail bool
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, preSucc, postSucc http.HandlerFunc, mw ...Middleware) *Server

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, l net.Listener) error

Serve starts the server and blocks until the context is canceled or a handler raises a success event. Serve waits for all workers to finish before returning.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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