http

package
v0.0.0-...-fc4206c Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package http provides the backbone for an HTTP server with some opinionated defaults.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware

type Middleware func(next http.Handler) http.Handler

Middleware for the HTTP Server.

func MiddlewareFunc

func MiddlewareFunc(middlewareFunc func(next http.HandlerFunc) http.HandlerFunc) Middleware

MiddlewareFunc returns middlewareFunc as Middleware.

type Option

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

Option is an option for the HTTP server.

func WithContextExtender

func WithContextExtender(contextExtender ...func(context.Context) context.Context) Option

WithContextExtender adds functions that extend request contexts.

func WithH2C

func WithH2C(h2c bool) Option

WithH2C returns an option that serves HTTP2 without TLS.

func WithMiddleware

func WithMiddleware(middleware ...Middleware) Option

WithMiddleware adds middleware.

func WithRouter

func WithRouter(router *mux.Router) Option

WithRouter returns an option that sets the Router of the server.

func WithServeMux

func WithServeMux(serveMux *http.ServeMux) Option

WithServeMux returns an option that sets the ServeMux of the server.

type Server

type Server struct {
	ServeMux *http.ServeMux
	Router   *mux.Router
	// contains filtered or unexported fields
}

Server wraps the HTTP server.

func NewServer

func NewServer(opts ...Option) *Server

NewServer instantiates a new HTTP server with the given options.

func (*Server) AddContextExtender

func (s *Server) AddContextExtender(contextExtender ...func(context.Context) context.Context)

AddContextExtender adds functions that extend request contexts.

func (*Server) AddMiddleware

func (s *Server) AddMiddleware(middleware ...Middleware)

AddMiddleware adds middleware.

func (*Server) GracefulStop

func (s *Server) GracefulStop() error

GracefulStop stops the HTTP server gracefully.

func (*Server) Serve

func (s *Server) Serve(lis net.Listener) error

Serve serves the HTTP server on lis.

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