hyped

package
v0.0.0-...-569481b Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCodec = JSON()

Functions

func Consumer

func Consumer[Req any](f ConsumerFunc[Req]) http.HandlerFunc

func ConsumerWith

func ConsumerWith[Req any](c Codec, f ConsumerFunc[Req]) http.HandlerFunc

func LeaderProvider

func LeaderProvider[Resp any](l api.LeaderChecker, f ProviderFunc[Resp]) http.HandlerFunc

func Processor

func Processor[Req, Resp any](f ProcessorFunc[Req, Resp]) http.HandlerFunc

func ProcessorWith

func ProcessorWith[Req, Resp any](c Codec, f ProcessorFunc[Req, Resp]) http.HandlerFunc

func Provider

func Provider[Resp any](f ProviderFunc[Resp]) http.HandlerFunc

func ProviderWith

func ProviderWith[Resp any](c Codec, f ProviderFunc[Resp]) http.HandlerFunc

Types

type Codec

type Codec interface {
	ContentType() string
	Marshal(v any) ([]byte, error)
	Unmarshal(data []byte, v any) error
}

func JSON

func JSON() Codec

func XML

func XML() Codec

type ConsumerFunc

type ConsumerFunc[Req any] func(r *Req) error

type Context

type Context interface {
	OK(v any)
	Err(err error)
}

func NewContext

func NewContext(c Codec, w http.ResponseWriter, r *http.Request) Context

type ProcessorFunc

type ProcessorFunc[Req, Resp any] func(r *Req) (*Resp, error)

type ProviderFunc

type ProviderFunc[Resp any] func() (*Resp, error)

type RPC

type RPC interface {
	Get(p api.Peer, id api.RpcID, v any) error
}

func NewRPC

func NewRPC(h *http.Client) RPC

func NewRPCWithCodec

func NewRPCWithCodec(h *http.Client, c Codec) RPC

type StatusCoder

type StatusCoder interface{ StatusCode() int }

Jump to

Keyboard shortcuts

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