httpserver

package
v0.55.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPServer

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

HTTPServer wraps the default net/http server to add the ability to use middlewares and support for the supervisor.Service interface.

func New

func New(srv *http.Server) *HTTPServer

New creates a new HTTPServer instance.

func (*HTTPServer) Addr

func (s *HTTPServer) Addr() net.Addr

Addr returns the server's network address.

func (*HTTPServer) SetHandler

func (s *HTTPServer) SetHandler(path string, handler http.Handler)

SetHandler sets the handler for the server.

func (*HTTPServer) Start

func (s *HTTPServer) Start(ctx context.Context) error

Start implements the supervisor.Service interface. It starts HTTP server.

func (*HTTPServer) Use

func (s *HTTPServer) Use(m ...Middleware)

Use adds a middleware. Middlewares will be called in the reverse order they were added.

func (*HTTPServer) Wait

func (s *HTTPServer) Wait() <-chan error

Wait implements the supervisor.Service interface.

type Middleware

type Middleware interface {
	Handle(http.Handler) http.Handler
}

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

func (MiddlewareFunc) Handle

func (m MiddlewareFunc) Handle(h http.Handler) http.Handler

type NullServer

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

func (*NullServer) Addr

func (s *NullServer) Addr() net.Addr

func (*NullServer) SetHandler

func (s *NullServer) SetHandler(string, http.Handler)

func (*NullServer) Start

func (s *NullServer) Start(ctx context.Context) error

func (*NullServer) Wait

func (s *NullServer) Wait() <-chan error

type Service

type Service interface {
	supervisor.Service
	SetHandler(string, http.Handler)
	Addr() net.Addr
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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