http

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func DocHandler

func DocHandler(assets Assets) http.HandlerFunc

func FileHandler

func FileHandler(cfg *config.Config, database db.DB, assets Assets) http.HandlerFunc

func HealthHandler

func HealthHandler(w http.ResponseWriter, _ *http.Request)

func MetaHandler

func MetaHandler(cfg *config.Config) http.HandlerFunc

func Pattern added in v0.4.1

func Pattern(r *http.Request) string

func ProfileHandler added in v0.4.1

func ProfileHandler(w http.ResponseWriter, r *http.Request)

func ShouldSendRaw

func ShouldSendRaw(r *http.Request) bool

func WithLogger

func WithLogger(next http.Handler) http.Handler

WithLogger adds a request scoped logger to the request context.

func WithMetrics added in v0.3.0

func WithMetrics(next http.Handler) http.Handler

WithMetrics will record metrics for the request.

func WithMiddleware

func WithMiddleware(handler http.Handler, middlewares ...Middleware) http.Handler

func WithRecover

func WithRecover(next http.Handler) http.Handler

WithRecover will recover from any panics and log them.

func WithRequestID

func WithRequestID(next http.Handler) http.Handler

WithRequestID adds a unique request ID to the request context.

Types

type Assets

type Assets interface {
	Doc(filename string) ([]byte, error)
	Template() *template.Template
	Serve(w http.ResponseWriter, r *http.Request)
}

type ContextKey

type ContextKey string
const (
	RequestIDContextKey ContextKey = "request_id"

	RequestIDHeader = "X-Request-ID"
)

type Middleware

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

type Service

type Service struct {
	*http.Server
}

func New

func New(cfg *config.Config, database db.DB, assets Assets) (*Service, error)

type StaticAssets added in v0.3.0

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

func NewAssets

func NewAssets(webFS fs.FS, docsFS fs.FS, readme []byte, extendHeadFile string) (*StaticAssets, error)

NewAssets holds the templates, static content and minifies accordingly.

func (*StaticAssets) CSS added in v0.3.0

func (a *StaticAssets) CSS() []byte

func (*StaticAssets) Doc added in v0.3.0

func (a *StaticAssets) Doc(filename string) ([]byte, error)

func (*StaticAssets) JS added in v0.3.0

func (a *StaticAssets) JS() []byte

func (*StaticAssets) README added in v0.3.0

func (a *StaticAssets) README() []byte

func (*StaticAssets) Serve added in v0.4.1

func (a *StaticAssets) Serve(w http.ResponseWriter, r *http.Request)

func (*StaticAssets) Template added in v0.3.0

func (a *StaticAssets) Template() *template.Template

Jump to

Keyboard shortcuts

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