http

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DocHandler

func DocHandler(name string, assets *Assets) http.HandlerFunc

func FileHandler

func FileHandler(cfg *config.Config, database db.DB, tmpl *template.Template) http.HandlerFunc

func HealthHandler

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

func IsSignedAndNotExpired

func IsSignedAndNotExpired(s *signer.Signer, r *http.Request) bool

func MetaHandler

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

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 WithMiddleware

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

WithMiddleware is a helper function to apply multiple middlewares to a 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 struct {
	// contains filtered or unexported fields
}

func NewAssets

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

NewAssets holds the templates, static content and minifies accordingly.

func (*Assets) CSS

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

func (*Assets) Doc

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

func (*Assets) JS

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

func (*Assets) ReadME

func (a *Assets) ReadME() []byte

func (*Assets) ServeCSS

func (a *Assets) ServeCSS(w http.ResponseWriter, r *http.Request)

func (*Assets) ServeJS

func (a *Assets) ServeJS(w http.ResponseWriter, r *http.Request)

func (*Assets) Template

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

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 Router

type Router struct {
	*http.ServeMux
}

func NewRouter

func NewRouter() *Router

func (*Router) Handle

func (r *Router) Handle(pattern string, handler http.Handler)

func (*Router) HandleFunc

func (r *Router) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))

type Service

type Service struct {
	*http.Server
}

func New

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

Jump to

Keyboard shortcuts

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