api

package
v0.0.0-...-d3c53b9 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	Healthy bool   `json:"healthy"` // Flag for server is healthy
	Version string `json:"version"` // Version of the API
	Name    string `json:"name"`    // Name of this API	or web service
}

This is intended to be wrapped & extended by a application API struct

func (*Base) AddCORS

func (b *Base) AddCORS(origins []string, r *mux.Router)

Add CORS middleware to the router

func (*Base) AddHealth

func (b *Base) AddHealth(r *mux.Router, prefix string)

AddHealth adds a health check endpoint to the API

func (*Base) AddLogging

func (b *Base) AddLogging(r *mux.Router)

Add logging middleware to the router in Apache Common Log Format.

func (*Base) AddMetrics

func (b *Base) AddMetrics(r *mux.Router, prefix string)

AddMetrics adds Prometheus metrics to the router

func (*Base) AddStatus

func (b *Base) AddStatus(r *mux.Router, prefix string)

AddStatus adds a status & info endpoint to the API

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (*Error) Error

func (e *Error) Error() string

type Status

type Status struct {
	Hostname  string `json:"hostname"`
	Uptime    string `json:"uptime"`
	GoVersion string `json:"goVersion"`
	*Base
}

Jump to

Keyboard shortcuts

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