apiutil

package
v0.0.0-...-b5dad65 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsOK

func IsOK(s Status) bool

Types

type Endpoint

type Endpoint[T any] func(*http.Request) (T, http.Header, Status)

func LogEndpoint

func LogEndpoint[T any](endpoint Endpoint[T], logger Logger) Endpoint[T]

func (Endpoint[T]) Process

func (e Endpoint[T]) Process(r *http.Request) (interface{}, http.Header, Status)

func (Endpoint[T]) ServeHTTP

func (e Endpoint[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)

type EndpointMiddleware

type EndpointMiddleware[T, U any] func(Endpoint[T]) *Endpoint[U]

func (EndpointMiddleware[T, U]) Wrap

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

type Status

type Status interface {
	error
	StatusCode() int
}

func NewStatus

func NewStatus(statusCode int, message string) Status

func NewStatusFromError

func NewStatusFromError(statusCode int, err error) Status

func StatusFromCode

func StatusFromCode(statusCode int) Status

func Statusf

func Statusf(statusCode int, format string, args ...interface{}) Status

type UntypedEndpoint

type UntypedEndpoint interface {
	http.Handler
	Process(r *http.Request) (interface{}, http.Header, Status)
}

type UntypedEndpointMiddleware

type UntypedEndpointMiddleware interface {
	Wrap(UntypedEndpoint) (UntypedEndpoint, error)
}

Jump to

Keyboard shortcuts

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