api

package
v0.0.0-...-1553226 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRoutes

func AddRoutes(router *mux.Router, m *monitor.Monitor, log *zap.Logger, useProxyHeaders bool)

func NoOp

func NoOp(h http.Handler) http.Handler

////////////////// MIDDLEWARE /////////////////////////////////

func WithMonitorAndLog

func WithMonitorAndLog(m *monitor.Monitor, log *zap.Logger, h RouteHandler) http.HandlerFunc

Types

type AddServerRequestBody

type AddServerRequestBody struct {
	// HostAndPort is the public address (in "host:port" format)
	HostAndPort string `json:"host_and_port"`
}

type ApiError

type ApiError struct {
	ResponseCode int
	// ResponseBody is the response body; must support json.Marshal
	ResponseBody interface{}
	Err          error
	LogData      []zap.Field
}

func NewApiError

func NewApiError(code int, body interface{}, err error, logData ...zap.Field) ApiError

NewApiError returns an ApiError using the given arguments. If body is a string, a struct will be used for the ResponseBody field that marshals to {"error":"..."}. Otherwise, the body is used for ResponseBody.

func NewApiErrorFromServerAddError

func NewApiErrorFromServerAddError(log *zap.Logger, err monitor.ServerAddError) ApiError

func (ApiError) Error

func (e ApiError) Error() string

func (ApiError) Unwrap

func (e ApiError) Unwrap() error

type RouteHandler

type RouteHandler func(w http.ResponseWriter, r *http.Request, m *monitor.Monitor, log *zap.Logger) error

Jump to

Keyboard shortcuts

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