micro-tests/server/grpc/proto/helloworld_micro.pb.go
Vasiliy Tolstov 957c488cbe api add tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-10 10:18:42 +03:00

53 lines
1.3 KiB
Go

// Code generated by protoc-gen-micro
// source: test.proto
package helloworld
import (
"context"
micro_api "github.com/unistack-org/micro/v3/api"
micro_client "github.com/unistack-org/micro/v3/client"
micro_server "github.com/unistack-org/micro/v3/server"
)
// NewTestEndpoints provides api endpoints metdata for Test service
func NewTestEndpoints() []*micro_api.Endpoint {
var endpoints []*micro_api.Endpoint
endpoint := &micro_api.Endpoint{
Name: "Test.Call",
Path: []string{"/api/v0/test/call/TEST"},
Method: []string{"POST"},
Body: "*",
Handler: "rpc",
}
endpoints = append(endpoints, endpoint)
return endpoints
}
// TestService interface
type TestService interface {
Call(context.Context, *Request, ...micro_client.CallOption) (*Response, error)
}
// Micro server stuff
// TestHandler server handler
type TestHandler interface {
Call(context.Context, *Request, *Response) error
}
// RegisterTestHandler registers server handler
func RegisterTestHandler(s micro_server.Server, sh TestHandler, opts ...micro_server.HandlerOption) error {
type test interface {
Call(context.Context, *Request, *Response) error
}
type Test struct {
test
}
h := &testHandler{sh}
for _, endpoint := range NewTestEndpoints() {
opts = append(opts, micro_api.WithEndpoint(endpoint))
}
return s.Handle(s.NewHandler(&Test{h}, opts...))
}