api

package
v0.0.0-...-3dc2347 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotOK = errors.New("non-OK response")

Functions

func AsStatus

func AsStatus(code codes.Code, err error) error

func Handler

func Handler[I Message, O any, D Dependencies](initDeps InitT[D], handler HandlerT[I, O, D]) http.HandlerFunc

func Translate

func Translate[O Message](t Translator[O], h http.HandlerFunc) http.HandlerFunc

Types

type Dependencies

type Dependencies interface{}

type HandlerT

type HandlerT[I Message, O any, D Dependencies] func(context.Context, I, D) (*O, error)

type InitT

type InitT[D Dependencies] func(context.Context) (D, error)

type Message

type Message interface {
	Validate() error
}

A message is a request/response type, used in api.Stub

type NoDeps

type NoDeps struct{}

func NoDepsInit

func NoDepsInit(context.Context) (*NoDeps, error)

type NoReturn

type NoReturn struct{}

type StubT

type StubT[I Message, O any] func(context.Context, I) (*O, error)

func Stub

func Stub[I Message, O any](client httpx.BasicClient, u url.URL) StubT[I, O]

func StubFromHandler

func StubFromHandler[I Message, O any, D Dependencies](client httpx.BasicClient, u url.URL, handler HandlerT[I, O, D]) StubT[I, O]

type Translator

type Translator[O Message] func(io.ReadCloser) (O, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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