api

package
v1.0.1-rc.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = &ErrorResponse{Code: 404, Status: "Resource not found."}

Functions

func Bind

func Bind(r *http.Request, dest interface{}) error

func Handler

func Handler(h HandlerFunc) http.HandlerFunc

func Render

func Render(w http.ResponseWriter, r *http.Request, response any) error

Types

type Binder

type Binder interface {
	Bind(value string) error
}

type ErrorResponse

type ErrorResponse struct {
	Err  error `json:"-"` // low-level runtime error
	Code int   `json:"-"` // http response status code

	Status  string `json:"status"`          // user-level status message
	Message string `json:"error,omitempty"` // application-level error message, for debugging
}

func Error

func Error(err error) *ErrorResponse

func InvalidRequestError

func InvalidRequestError(err error) *ErrorResponse

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

func (*ErrorResponse) Render

type HandlerFunc

type HandlerFunc func(http.ResponseWriter, *http.Request) error

type Hex

type Hex []byte

func (*Hex) Bind

func (h *Hex) Bind(value string) error

func (Hex) MarshalJSON

func (h Hex) MarshalJSON() ([]byte, error)

func (*Hex) UnmarshalJSON

func (h *Hex) UnmarshalJSON(data []byte) error

type HexSlice

type HexSlice []Hex

func (*HexSlice) Bind

func (hs *HexSlice) Bind(value string) error

type Uint64Slice

type Uint64Slice []uint64

func (*Uint64Slice) Bind

func (us *Uint64Slice) Bind(value string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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