http_handler

package
v0.0.0-...-bbb319f Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

func NewHandler

func NewHandler(opts HandlerOpts) (*Handler, error)

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w ResponseWriter, req Request)

type HandlerOpts

type HandlerOpts struct {
	// DNSHandler is required.
	DNSHandler dns_handler.Handler

	// Path specifies the query endpoint. If it is empty, Handler
	// will ignore the request path.
	Path string

	// SrcIPHeader specifies the header that contain client source address.
	// "True-Client-IP" "X-Real-IP" "X-Forwarded-For" will parse automatically.
	SrcIPHeader string

	// Logger specifies the logger which Handler writes its log to.
	// Default is a nop logger.
	Logger *zap.Logger
}

func (*HandlerOpts) Init

func (opts *HandlerOpts) Init() error
type Header interface {
	Get(key string) string
	Set(key string, value string)
}

type Request

type Request interface {
	URL() *url.URL
	TLS() *TlsInfo
	Body() io.ReadCloser
	Header() Header
	Method() string
	Context() context.Context
	RequestURI() string
	GetRemoteAddr() string
	SetRemoteAddr(addr string)
}

type ResponseWriter

type ResponseWriter interface {
	Header() Header
	Write([]byte) (int, error)
	WriteHeader(statusCode int)
}

type TlsInfo

type TlsInfo struct {
	Version            uint16
	ServerName         string
	NegotiatedProtocol string
}

Jump to

Keyboard shortcuts

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