handlers

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chapter

func Chapter(w http.ResponseWriter, req *http.Request)

Chapter is the handler for the documentation chapters

func Config

func Config(w http.ResponseWriter, req *http.Request)

Config returns the configuration of the heartbeats server

func Dashboard

func Dashboard(w http.ResponseWriter, req *http.Request)

HandlerDashboard is the handler for the /dashboard endpoint

func Docs

func Docs(w http.ResponseWriter, req *http.Request)

Docs is the handler for the docs page

func FormatOutput

func FormatOutput(outputFormat string, textTemplate string, output interface{}) (string, error)

FormatOutput formats the output according to outputFormat

func GetOutputFormat

func GetOutputFormat(req *http.Request) string

CheckOutput checks if the output format is supported

func Healthz

func Healthz(w http.ResponseWriter, req *http.Request)

Healthz is the handler for the /healthz endpoint

func History

func History(w http.ResponseWriter, req *http.Request)

HandlerHistory is the handler for the /history endpoint

func Home

func Home(w http.ResponseWriter, req *http.Request)

Home is the handler for the / endpoint

func IsValidUUID

func IsValidUUID(u string) bool

IsValidUUID checks if the given string is a valid UUID

func LogPingRequest

func LogPingRequest(req *http.Request, heartbeatName string)

func LogRequest

func LogRequest(req *http.Request)

LogRequest logs the request

func NotFound

func NotFound(w http.ResponseWriter, req *http.Request)

NotFound is the handler for the 404 page

func ParseTemplates

func ParseTemplates(name string, templates []string, data any, w http.ResponseWriter)

ParseBaseTemplates parses the templates for docs and writes the output to the response writer

func Ping

func Ping(w http.ResponseWriter, req *http.Request)

Ping is the handler for the /ping/<heartbeat> endpoint

func PingFail

func PingFail(w http.ResponseWriter, req *http.Request)

PingFail is the handler for the /ping/<heartbeat>/fail endpoint

func PingHelp

func PingHelp(w http.ResponseWriter, req *http.Request)

PingHelp is the handler for the /ping endpoint

func Status

func Status(w http.ResponseWriter, req *http.Request)

Status is the handler for the /status endpoint

func Version

func Version(w http.ResponseWriter, req *http.Request)

Version is the handler for the /version endpoint

func WriteOutput

func WriteOutput(w http.ResponseWriter, statusCode int, outputFormat string, output interface{}, textTemplate string)

WriteOutput writes the output to the response writer

- w is the response writer - statusCode is the HTTP status code - outputFormat is the format of the output (json, yaml, yml, txt, text) - output is the data to render the template with - textTmpl is the template to use for the text output

Types

type HeartbeatStatus

type HeartbeatStatus struct {
	Name     string    `json:"name"`
	Status   string    `json:"status"`
	LastPing time.Time `json:"lastPing"`
}

HeartbeatStatus represents a heartbeat status

func (*HeartbeatStatus) TimeAgo

func (h *HeartbeatStatus) TimeAgo(t time.Time) string

TimeAgo returns a string representing the time since the given time

type ResponseStatus

type ResponseStatus struct {
	Status string `json:"status"`
	Error  string `json:"error"`
}

ResponseStatus represents a response

Jump to

Keyboard shortcuts

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