api

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: MIT Imports: 11 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"` // Whether the 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 the application API struct

func (*Base) AddHealth

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

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)

AddMetrics adds Prometheus metrics to the router

func (*Base) AddStatus

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

AddStatus adds a status & info endpoint to the API

func (*Base) CORSHandler

func (b *Base) CORSHandler(origins []string, r *mux.Router) http.Handler

CORSHandler sets up CORS using http.Handler it can not be added as middleware

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