Documentation ¶
Index ¶
- Variables
- func Call[Req any, Res any](client *ServiceClient, req *Request[Req, Res]) (*Res, error)
- func DecodeJSON[T any](r io.Reader) (T, error)
- func DecodeReq[T any](r *http.Request) (T, error)
- func EncodeJSON[T any](w http.ResponseWriter, payload *T) error
- func JsonError(w http.ResponseWriter, statusCode int, err error)
- func Register[Req any, Res any](service *Service, name string, handler ServiceHandler[Req, Res])
- type Request
- type Service
- type ServiceClient
- type ServiceHandler
- type ServiceImpl
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidRequest = errors.New("invalid request payload") ErrNoResponse = errors.New("no response") )
Functions ¶
func Call ¶
func Call[Req any, Res any]( client *ServiceClient, req *Request[Req, Res], ) (*Res, error)
func EncodeJSON ¶
func EncodeJSON[T any](w http.ResponseWriter, payload *T) error
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(name string, addr string, service ServiceImpl) *Service
type ServiceClient ¶
type ServiceClient struct {
// contains filtered or unexported fields
}
func NewServiceClient ¶
func NewServiceClient(name, addr string) (*ServiceClient, error)
type ServiceHandler ¶
type ServiceImpl ¶
type ServiceImpl interface {
Init(service *Service)
}
Click to show internal directories.
Click to hide internal directories.