api

package
v0.0.0-...-ebc0785 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, r *http.Request, e AppError)

Error returns error response.

func HandleError

func HandleError(w http.ResponseWriter, r *http.Request, e string, code int)

HandleError returns default error handler.

func Handlers

func Handlers() map[string]http.Handler

Handlers return a map of api handlers.

func NewRouter

func NewRouter(handlers map[string]http.Handler, apis ...string) (*openapimux.OpenAPIMux, error)

NewRouter returns a router.

func Success

func Success(w http.ResponseWriter, data interface{}, code int)

Success returns successful response.

Types

type AppError

type AppError struct {
	Code    int
	Message string
	Err     error
}

AppError struct for handled error.

type HealthCheckHandler

type HealthCheckHandler struct{}

HealthCheckHandler standard handler for healthCheck endpoint - outputs OK.

func (HealthCheckHandler) ServeHTTP

func (h HealthCheckHandler) 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