Documentation ¶
Index ¶
- Constants
- func DecodeRequest[Req any](_ context.Context, msg json.RawMessage) (any, error)
- func FieldNames(i interface{}) []string
- func MountHandlers(logger log.Logger, mux Mux, services ...*Service)
- func NewServer(serviceName string, ecm EndpointCodecMap, logger log.Logger) http.Handlerdeprecated
- func TypeSchema(t reflect.Type, defs map[string]jtd.Schema) *jtd.Schema
- type DecodeRequestFunc
- type EncodeResponseFunc
- type Endpoint
- type EndpointCodec
- type EndpointCodecMap
- type EndpointCodecOption
- type EndpointMeta
- type Failer
- type Meta
- type Mux
- type Resulter
- type RootMeta
- type Service
- type StandardMethod
Constants ¶
View Source
const (
// ContentType defines the content type to be served.
ContentType = "application/json; charset=utf-8"
)
Variables ¶
This section is empty.
Functions ¶
func DecodeRequest ¶
func FieldNames ¶
func FieldNames(i interface{}) []string
func MountHandlers ¶
MountHandlers mounts all the service endpoints onto the mux Endpoints are mounted at
POST /rpc/<service>/<method>
Meta data is serviced from
GET /rpc GET /rpc/<service>
Types ¶
type DecodeRequestFunc ¶
type DecodeRequestFunc func(context.Context, json.RawMessage) (request interface{}, err error)
type EncodeResponseFunc ¶
type EncodeResponseFunc func(context.Context, interface{}) (response json.RawMessage, err error)
type Endpoint ¶
Endpoint is an abstract rpc endpoint
func MakeStandardEndpoint ¶
func MakeStandardEndpoint[Req any, Res any](method StandardMethod[Req, Res]) Endpoint
type EndpointCodec ¶
type EndpointCodec struct { Endpoint Endpoint Decode DecodeRequestFunc Help string ParamNames []string // contains filtered or unexported fields }
EndpointCodec defines a server Endpoint and its associated codecs
func MakeStandardEndpointCodec ¶
func MakeStandardEndpointCodec[Req any, Res any](method StandardMethod[Req, Res], help string, opts ...EndpointCodecOption) EndpointCodec
MakeStandardEndpointCodec
type EndpointCodecMap ¶
type EndpointCodecMap map[string]EndpointCodec
EndpointCodecMap maps the Request.Method to the proper EndpointCodec
type EndpointCodecOption ¶
type EndpointCodecOption func(*EndpointCodec)
func NoNilResponse ¶
func NoNilResponse() EndpointCodecOption
type EndpointMeta ¶
type Service ¶
Service
func NewService ¶
func NewService(name, help string, ecm EndpointCodecMap) *Service
NewService creates a new Service
Click to show internal directories.
Click to hide internal directories.