handlers

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JsonErrorHandler

func JsonErrorHandler(err string, code int) http.Handler

func Observability

func Observability() http.Handler

Observability handler adds an /metrics endpoint for prometheus other observability features can and will be added in the future

func StaticInfo

func StaticInfo(inf map[string]interface{}) (http.Handler, error)

StaticInfo is a handler that will render a static map[string]any to an endpoint this is useful to expose static information like build version, or enabled/disabled features that won't change over the lifecycle of the application and indicate the clients how to behave, e.g. if authentication is disabled.

func StatusErr

func StatusErr(status int) http.Handler

func TemplateWithRequest

func TemplateWithRequest(inTmpl string, data func(r *http.Request) map[string]interface{}) func(w http.ResponseWriter, r *http.Request)

Types

type HttpErr

type HttpErr struct {
	Error string
	Code  int
}

type Info

type Info struct {
	Version   string `json:"version"`
	BuildTime string `json:"buildtime"`
	Commit    string `json:"commit"`
}
type Link struct {
	Text  string
	Url   string
	Child []Link
}

type SimpleText

type SimpleText struct {
	Text  string
	Links []Link
}

SimpleText Is a simple handler that will print a list of navigation destination based on the map passed upon creation.

func (SimpleText) ServeHTTP

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

type SpaHandler

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

func NewSpaHAndler

func NewSpaHAndler(inputFs fs.FS, fsSubDir, pathPrefix string) (SpaHandler, error)

func (SpaHandler) ServeHTTP

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

Jump to

Keyboard shortcuts

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