rest

package module
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOKReply

func NewOKReply[Resp Response](value Resp) responseWithStatus[Resp]

func Wrap

func Wrap[Req any, Resp any, ReqPtr PtrToRequest[Req], RespPtr PtrToResponse[Resp]](handler Handler[Req, Resp, ReqPtr, RespPtr], errTranslator ErrorTranslator, errHandler ErrorHandler) http.HandlerFunc

Types

type ErrorHandler

type ErrorHandler interface {
	HandleError(error)
}

type ErrorHandlerFunc

type ErrorHandlerFunc func(error)

func (ErrorHandlerFunc) HandleError

func (f ErrorHandlerFunc) HandleError(err error)

type ErrorTranslator

type ErrorTranslator interface {
	TranslateError(error) uint
}

type ErrorTranslatorFunc

type ErrorTranslatorFunc func(error) uint

func (ErrorTranslatorFunc) TranslateError

func (f ErrorTranslatorFunc) TranslateError(err error) uint

type Handler

type Handler[Req any, Resp any, ReqPtr PtrToRequest[Req], RespPtr PtrToResponse[Resp]] func(context.Context, *Req) (*Resp, error)

func (Handler[Req, Rep, ReqPtr, RespPtr]) ToHTTPHandler

func (h Handler[Req, Rep, ReqPtr, RespPtr]) ToHTTPHandler(errTranslator ErrorTranslator, errHandler ErrorHandler) http.HandlerFunc

type PtrToRequest

type PtrToRequest[T any] interface {
	Request
	*T
}

type PtrToResponse

type PtrToResponse[T any] interface {
	Response
	*T
}

type Request

type Request interface {
	easyjson.Unmarshaler
}

type Response

type Response interface {
	easyjson.Marshaler
}

Jump to

Keyboard shortcuts

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