pkghttp

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const StatusClientClosedRequest = 499

Variables

This section is empty.

Functions

func InitRequest added in v0.11.0

func InitRequest(r *http.Request, observeLatencyMillis latencyMillisObserver) *http.Request

func Pretty

func Pretty(r *http.Request) bool

func RespondError

func RespondError(w http.ResponseWriter, r *http.Request, statusCode int, err error, errResp ...any)

func RespondErrorf

func RespondErrorf(w http.ResponseWriter, r *http.Request, statusCode int, format string, a ...any)

func RespondJSON

func RespondJSON(w http.ResponseWriter, r *http.Request, statusCode int, obj any, optErrData ...errData)

func RespondNotFound

func RespondNotFound(w http.ResponseWriter)

func RespondText

func RespondText(w http.ResponseWriter, r *http.Request, statusCode int, text string)

Types

type DirectoryHandler

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

func (*DirectoryHandler) HandleDirectory added in v0.15.0

func (h *DirectoryHandler) HandleDirectory(pattern string, dirLister DirectoryLister)

func (*DirectoryHandler) HandleMetadata added in v0.15.0

func (h *DirectoryHandler) HandleMetadata(pattern string, handler MetadataHandler)

func (*DirectoryHandler) MarshalJSON

func (n *DirectoryHandler) MarshalJSON() ([]byte, error)

func (*DirectoryHandler) ServeHTTP

func (h *DirectoryHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type DirectoryLister

type DirectoryLister func(http.ResponseWriter, *http.Request) ([]string, *http.Request, error)

type MetadataHandler added in v0.15.0

type MetadataHandler interface {
	GetMetadata(http.ResponseWriter, *http.Request) (any, error)
}

type MetadataHandlerFunc added in v0.15.0

type MetadataHandlerFunc func(http.ResponseWriter, *http.Request) (any, error)

func (MetadataHandlerFunc) GetMetadata added in v0.15.0

func (f MetadataHandlerFunc) GetMetadata(w http.ResponseWriter, r *http.Request) (any, error)

type TokenHandler added in v0.15.0

type TokenHandler struct{ MetadataHandler }

Jump to

Keyboard shortcuts

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