beaconhttp

package
v0.0.0-...-1f8a15b Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleEndpoint

func HandleEndpoint[T any](h EndpointHandler[T]) http.HandlerFunc

func HandleEndpointFunc

func HandleEndpointFunc[T any](h EndpointHandlerFunc[T]) http.HandlerFunc

Types

type EndpointError

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

func NewEndpointError

func NewEndpointError(code int, message string) *EndpointError

func WrapEndpointError

func WrapEndpointError(err error) *EndpointError

func (EndpointError) Error

func (e EndpointError) Error() string

func (*EndpointError) WriteTo

func (e *EndpointError) WriteTo(w http.ResponseWriter)

type EndpointHandler

type EndpointHandler[T any] interface {
	Handle(r *http.Request) (T, error)
}

type EndpointHandlerFunc

type EndpointHandlerFunc[T any] func(r *http.Request) (T, error)

func (EndpointHandlerFunc[T]) Handle

func (e EndpointHandlerFunc[T]) Handle(r *http.Request) (T, error)

Jump to

Keyboard shortcuts

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