update after protoc-gen-micro changes

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-02-27 13:51:39 +03:00
parent c5fb53c0f1
commit 267b29b658
28 changed files with 394 additions and 517 deletions

View File

@@ -1,3 +1,3 @@
package grpc
//go:generate protoc -I./proto -I$GOPATH/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.9.5/third_party/googleapis -I. --go-grpc_out=paths=source_relative:./proto --go_out=paths=source_relative:./proto --micro_out=paths=source_relative:./proto proto/test.proto
//go:generate protoc -I./proto -I$GOPATH/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.9.5/third_party/googleapis -I. --go-grpc_out=paths=source_relative:./proto --go_out=paths=source_relative:./proto --micro_out=components=micro|rpc,debug=true,standalone=true,paths=source_relative:./gproto proto/test.proto

View File

@@ -0,0 +1,30 @@
// Code generated by protoc-gen-micro
// source: test.proto
package helloworld
import (
context "context"
proto "github.com/unistack-org/micro-tests/server/grpc/proto"
api "github.com/unistack-org/micro/v3/api"
client "github.com/unistack-org/micro/v3/client"
)
func NewTestEndpoints() []*api.Endpoint {
return []*api.Endpoint{
&api.Endpoint{
Name: "Test.Call",
Path: []string{"/api/v0/test/call/TEST"},
Method: []string{"POST"},
Body: "*",
Handler: "rpc",
},
}
}
type TestClient interface {
Call(ctx context.Context, req *proto.Request, opts ...client.CallOption) (*proto.Response, error)
}
type TestServer interface {
Call(ctx context.Context, req *proto.Request, rsp *proto.Response) error
}

View File

@@ -0,0 +1,51 @@
// Code generated by protoc-gen-micro
// source: test.proto
package helloworld
import (
context "context"
proto "github.com/unistack-org/micro-tests/server/grpc/proto"
api "github.com/unistack-org/micro/v3/api"
client "github.com/unistack-org/micro/v3/client"
server "github.com/unistack-org/micro/v3/server"
)
type testClient struct {
c client.Client
name string
}
func NewTestClient(name string, c client.Client) TestClient {
return &testClient{c: c, name: name}
}
func (c *testClient) Call(ctx context.Context, req *proto.Request, opts ...client.CallOption) (*proto.Response, error) {
rsp := &proto.Response{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, opts...)
if err != nil {
return nil, err
}
return rsp, nil
}
type testServer struct {
TestServer
}
func (h *testServer) Call(ctx context.Context, req *proto.Request, rsp *proto.Response) error {
return h.TestServer.Call(ctx, req, rsp)
}
func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOption) error {
type test interface {
Call(ctx context.Context, req *proto.Request, rsp *proto.Response) error
}
type Test struct {
test
}
h := &testServer{sh}
for _, endpoint := range NewTestEndpoints() {
opts = append(opts, api.WithEndpoint(endpoint))
}
return s.Handle(s.NewHandler(&Test{h}, opts...))
}

View File

@@ -9,6 +9,7 @@ import (
protocodec "github.com/unistack-org/micro-codec-proto/v3"
regRouter "github.com/unistack-org/micro-router-register/v3"
gserver "github.com/unistack-org/micro-server-grpc/v3"
gpb "github.com/unistack-org/micro-tests/server/grpc/gproto"
pb "github.com/unistack-org/micro-tests/server/grpc/proto"
"github.com/unistack-org/micro/v3/broker"
"github.com/unistack-org/micro/v3/client"
@@ -54,7 +55,7 @@ func TestGRPCServer(t *testing.T) {
rtr := regRouter.NewRouter(router.Register(r))
h := &testServer{}
err = pb.RegisterTestHandler(s, h)
err = gpb.RegisterTestServer(s, h)
if err != nil {
t.Fatalf("can't register handler: %v", err)
}

View File

@@ -215,9 +215,12 @@ var file_test_proto_rawDesc = []byte{
0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c,
0x64, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x21, 0x82, 0xd3, 0xe4, 0x93,
0x02, 0x1b, 0x22, 0x16, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x30, 0x2f, 0x74, 0x65, 0x73, 0x74,
0x2f, 0x63, 0x61, 0x6c, 0x6c, 0x2f, 0x54, 0x45, 0x53, 0x54, 0x3a, 0x01, 0x2a, 0x42, 0x0e, 0x5a,
0x0c, 0x2e, 0x3b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x2f, 0x63, 0x61, 0x6c, 0x6c, 0x2f, 0x54, 0x45, 0x53, 0x54, 0x3a, 0x01, 0x2a, 0x42, 0x42, 0x5a,
0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x6e, 0x69, 0x73,
0x74, 0x61, 0x63, 0x6b, 0x2d, 0x6f, 0x72, 0x67, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x74,
0x65, 0x73, 0x74, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x67, 0x72, 0x70, 0x63,
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c,
0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@@ -2,7 +2,7 @@ syntax = "proto3";
package helloworld;
option go_package = ".;helloworld";
option go_package = "github.com/unistack-org/micro-tests/server/grpc/proto;helloworld";
import "google/api/annotations.proto";
service Test {

View File

@@ -1,52 +0,0 @@
// 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...))
}

View File

@@ -1,46 +0,0 @@
// Code generated by protoc-gen-micro
// source: test.proto
package helloworld
import (
"context"
micro_client "github.com/unistack-org/micro/v3/client"
micro_server "github.com/unistack-org/micro/v3/server"
)
var (
_ micro_server.Option
_ micro_client.Option
)
type testService struct {
c micro_client.Client
name string
}
// Micro client stuff
// NewTestService create new service client
func NewTestService(name string, c micro_client.Client) TestService {
return &testService{c: c, name: name}
}
func (c *testService) Call(ctx context.Context, req *Request, opts ...micro_client.CallOption) (*Response, error) {
rsp := &Response{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, opts...)
if err != nil {
return nil, err
}
return rsp, nil
}
// Micro server stuff
type testHandler struct {
TestHandler
}
func (h *testHandler) Call(ctx context.Context, req *Request, rsp *Response) error {
return h.TestHandler.Call(ctx, req, rsp)
}

View File

@@ -1,3 +1,3 @@
package http
//go:generate protoc -I./proto -I. -I/home/vtolstov/.cache/go-path/pkg/mod/github.com/grpc-ecosystem/grpc-gateway/v2@v2.1.0 -I/home/vtolstov/.cache/go-path/pkg/mod/github.com/grpc-ecosystem/grpc-gateway/v2@v2.1.0/third_party/googleapis --go-grpc_out=paths=source_relative:./proto --go_out=paths=source_relative:./proto --micro_out=components=micro|http,debug=true,paths=source_relative:./proto proto/test.proto
//go:generate protoc -I./proto -I. -I/home/vtolstov/.cache/go-path/pkg/mod/github.com/grpc-ecosystem/grpc-gateway/v2@v2.1.0 -I/home/vtolstov/.cache/go-path/pkg/mod/github.com/grpc-ecosystem/grpc-gateway/v2@v2.1.0/third_party/googleapis --go_out=paths=source_relative:./proto --micro_out=components=micro|http,debug=true,paths=source_relative:./proto proto/test.proto

View File

@@ -2,9 +2,10 @@ package handler
import (
"context"
"net/http"
httpsrv "github.com/unistack-org/micro-server-http/v3"
pb "github.com/unistack-org/micro-tests/client/http/proto"
"net/http"
)
type GithubHandler struct{}
@@ -16,7 +17,7 @@ func NewGithubHandler() *GithubHandler {
func (h *GithubHandler) LookupUser(ctx context.Context, req *pb.LookupUserReq, rsp *pb.LookupUserRsp) error {
if req.GetUsername() == "" || req.GetUsername() != "vtolstov" {
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return &pb.Error{Message: "name is not correct"}
return httpsrv.SetError(&pb.Error{Message: "name is not correct"})
}
rsp.Name = "Vasiliy Tolstov"
httpsrv.SetRspCode(ctx, http.StatusOK)

View File

@@ -39,7 +39,7 @@ func (h *Handler) Call(ctx context.Context, req *pb.CallReq, rsp *pb.CallRsp) er
if len(req.Nested.Uint64Args) != 3 || req.Nested.Uint64Args[2].Value != 3 {
h.t.Fatalf("invalid reflect merging")
}
md, ok := metadata.FromContext(ctx)
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
h.t.Fatalf("context without metadata")
}
@@ -56,8 +56,7 @@ func (h *Handler) Call(ctx context.Context, req *pb.CallReq, rsp *pb.CallRsp) er
func (h *Handler) CallError(ctx context.Context, req *pb.CallReq1, rsp *pb.CallRsp1) error {
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return &pb.Error{Msg: "my_error"}
return nil
return httpsrv.SetError(&pb.Error{Msg: "my_error"})
}
func TestNativeClientServer(t *testing.T) {
@@ -82,7 +81,7 @@ func TestNativeClientServer(t *testing.T) {
)
h := &Handler{t: t}
pb.RegisterTestHandler(srv, h)
pb.RegisterTestServer(srv, h)
// start server
if err := srv.Start(); err != nil {
@@ -105,7 +104,7 @@ func TestNativeClientServer(t *testing.T) {
cli := client.NewClientCallOptions(httpcli.NewClient(client.ContentType("application/json"), client.Codec("application/json", jsonpbcodec.NewCodec())), client.WithAddress(fmt.Sprintf("http://%s", service[0].Nodes[0].Address)))
svc := pb.NewTestService("helloworld", cli)
svc := pb.NewTestClient("helloworld", cli)
rsp, err := svc.Call(ctx, &pb.CallReq{
Name: "my_name",
Nested: &pb.Nested{Uint64Args: []*wrapperpb.UInt64Value{
@@ -145,7 +144,7 @@ func TestNativeServer(t *testing.T) {
)
h := &Handler{t: t}
pb.RegisterTestHandler(srv, h)
pb.RegisterTestServer(srv, h)
// start server
if err := srv.Start(); err != nil {

View File

@@ -1,126 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package pb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// TestClient is the client API for Test service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type TestClient interface {
Call(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*CallRsp, error)
CallError(ctx context.Context, in *CallReq1, opts ...grpc.CallOption) (*CallRsp1, error)
}
type testClient struct {
cc grpc.ClientConnInterface
}
func NewTestClient(cc grpc.ClientConnInterface) TestClient {
return &testClient{cc}
}
func (c *testClient) Call(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*CallRsp, error) {
out := new(CallRsp)
err := c.cc.Invoke(ctx, "/test.Test/Call", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *testClient) CallError(ctx context.Context, in *CallReq1, opts ...grpc.CallOption) (*CallRsp1, error) {
out := new(CallRsp1)
err := c.cc.Invoke(ctx, "/test.Test/CallError", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// TestServer is the server API for Test service.
// All implementations must embed UnimplementedTestServer
// for forward compatibility
type TestServer interface {
Call(context.Context, *CallReq) (*CallRsp, error)
CallError(context.Context, *CallReq1) (*CallRsp1, error)
mustEmbedUnimplementedTestServer()
}
// UnimplementedTestServer must be embedded to have forward compatible implementations.
type UnimplementedTestServer struct {
}
func (*UnimplementedTestServer) Call(context.Context, *CallReq) (*CallRsp, error) {
return nil, status.Errorf(codes.Unimplemented, "method Call not implemented")
}
func (*UnimplementedTestServer) CallError(context.Context, *CallReq1) (*CallRsp1, error) {
return nil, status.Errorf(codes.Unimplemented, "method CallError not implemented")
}
func (*UnimplementedTestServer) mustEmbedUnimplementedTestServer() {}
func RegisterTestServer(s *grpc.Server, srv TestServer) {
s.RegisterService(&_Test_serviceDesc, srv)
}
func _Test_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CallReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TestServer).Call(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/test.Test/Call",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TestServer).Call(ctx, req.(*CallReq))
}
return interceptor(ctx, in, info, handler)
}
func _Test_CallError_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CallReq1)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TestServer).CallError(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/test.Test/CallError",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TestServer).CallError(ctx, req.(*CallReq1))
}
return interceptor(ctx, in, info, handler)
}
var _Test_serviceDesc = grpc.ServiceDesc{
ServiceName: "test.Test",
HandlerType: (*TestServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Call",
Handler: _Test_Call_Handler,
},
{
MethodName: "CallError",
Handler: _Test_CallError_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "test.proto",
}

View File

@@ -3,45 +3,36 @@
package pb
import (
"context"
micro_api "github.com/unistack-org/micro/v3/api"
micro_client "github.com/unistack-org/micro/v3/client"
context "context"
api "github.com/unistack-org/micro/v3/api"
client "github.com/unistack-org/micro/v3/client"
)
// NewTestEndpoints provides api endpoints metdata for Test service
func NewTestEndpoints() []*micro_api.Endpoint {
endpoints := make([]*micro_api.Endpoint, 0, 2)
var endpoint *micro_api.Endpoint
endpoint = &micro_api.Endpoint{
Name: "Test.Call",
Path: []string{"/v1/test/call/{name}"},
Method: []string{"POST"},
Body: "*",
Handler: "rpc",
func NewTestEndpoints() []*api.Endpoint {
return []*api.Endpoint{
&api.Endpoint{
Name: "Test.Call",
Path: []string{"/v1/test/call/{name}"},
Method: []string{"POST"},
Body: "*",
Handler: "rpc",
},
&api.Endpoint{
Name: "Test.CallError",
Path: []string{"/v1/test/callerror/{name}"},
Method: []string{"POST"},
Body: "*",
Handler: "rpc",
},
}
endpoints = append(endpoints, endpoint)
endpoint = &micro_api.Endpoint{
Name: "Test.CallError",
Path: []string{"/v1/test/callerror/{name}"},
Method: []string{"POST"},
Body: "*",
Handler: "rpc",
}
endpoints = append(endpoints, endpoint)
return endpoints
}
// TestService interface
type TestService interface {
Call(context.Context, *CallReq, ...micro_client.CallOption) (*CallRsp, error)
CallError(context.Context, *CallReq1, ...micro_client.CallOption) (*CallRsp1, error)
type TestClient interface {
Call(ctx context.Context, req *CallReq, opts ...client.CallOption) (*CallRsp, error)
CallError(ctx context.Context, req *CallReq1, opts ...client.CallOption) (*CallRsp1, error)
}
// Micro server stuff
// TestHandler server handler
type TestHandler interface {
Call(context.Context, *CallReq, *CallRsp) error
CallError(context.Context, *CallReq1, *CallRsp1) error
type TestServer interface {
Call(ctx context.Context, req *CallReq, rsp *CallRsp) error
CallError(ctx context.Context, req *CallReq1, rsp *CallRsp1) error
}

View File

@@ -3,115 +3,79 @@
package pb
import (
"context"
"fmt"
// "net/http"
micro_client_http "github.com/unistack-org/micro-client-http/v3"
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"
context "context"
v3 "github.com/unistack-org/micro-client-http/v3"
api "github.com/unistack-org/micro/v3/api"
client "github.com/unistack-org/micro/v3/client"
server "github.com/unistack-org/micro/v3/server"
)
var (
_ micro_server.Option
_ micro_client.Option
)
type testService struct {
c micro_client.Client
type testClient struct {
c client.Client
name string
}
// Micro client stuff
// NewTestService create new service client
func NewTestService(name string, c micro_client.Client) TestService {
return &testService{c: c, name: name}
func NewTestClient(name string, c client.Client) TestClient {
return &testClient{c: c, name: name}
}
func (c *testService) Call(ctx context.Context, req *CallReq, opts ...micro_client.CallOption) (*CallRsp, error) {
func (c *testClient) Call(ctx context.Context, req *CallReq, opts ...client.CallOption) (*CallRsp, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
nopts := append(opts,
micro_client_http.Method("POST"),
micro_client_http.Path("/v1/test/call/{name}"),
micro_client_http.Body("*"),
micro_client_http.ErrorMap(errmap),
opts = append(opts,
v3.ErrorMap(errmap),
v3.Method("POST"),
v3.Path("/v1/test/call/{name}"),
v3.Body("*"),
)
rsp := &CallRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, nopts...)
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, opts...)
if err != nil {
return nil, err
}
return rsp, nil
}
func (c *testService) CallError(ctx context.Context, req *CallReq1, opts ...micro_client.CallOption) (*CallRsp1, error) {
func (c *testClient) CallError(ctx context.Context, req *CallReq1, opts ...client.CallOption) (*CallRsp1, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
nopts := append(opts,
micro_client_http.Method("POST"),
micro_client_http.Path("/v1/test/callerror/{name}"),
micro_client_http.Body("*"),
micro_client_http.ErrorMap(errmap),
opts = append(opts,
v3.ErrorMap(errmap),
v3.Method("POST"),
v3.Path("/v1/test/callerror/{name}"),
v3.Body("*"),
)
rsp := &CallRsp1{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.CallError", req), rsp, nopts...)
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.CallError", req), rsp, opts...)
if err != nil {
return nil, err
}
return rsp, nil
}
// Micro server stuff
type testHandler struct {
TestHandler
type testServer struct {
TestServer
}
func (h *testHandler) Call(ctx context.Context, req *CallReq, rsp *CallRsp) error {
return h.TestHandler.Call(ctx, req, rsp)
func (h *testServer) Call(ctx context.Context, req *CallReq, rsp *CallRsp) error {
return h.TestServer.Call(ctx, req, rsp)
}
/*
func (h *testHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Printf("new request: %#+v\n", r)
// HANDLE ALL STUFF
}
*/
func (h *testHandler) CallError(ctx context.Context, req *CallReq1, rsp *CallRsp1) error {
return h.TestHandler.CallError(ctx, req, rsp)
func (h *testServer) CallError(ctx context.Context, req *CallReq1, rsp *CallRsp1) error {
return h.TestServer.CallError(ctx, req, rsp)
}
/*
func (h *testHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Printf("new request: %#+v\n", r)
// HANDLE ALL STUFF
}
*/
// Error method to satisfy error interface
func (e *Error) Error() string {
return fmt.Sprintf("%#v", e)
}
// RegisterTestHandler registers server handler
func RegisterTestHandler(s micro_server.Server, sh TestHandler, opts ...micro_server.HandlerOption) error {
func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOption) error {
type test interface {
Call(context.Context, *CallReq, *CallRsp) error
CallError(context.Context, *CallReq1, *CallRsp1) error
// ServeHTTP(http.ResponseWriter, *http.Request)
Call(ctx context.Context, req *CallReq, rsp *CallRsp) error
CallError(ctx context.Context, req *CallReq1, rsp *CallRsp1) error
}
type Test struct {
test
}
h := &testHandler{sh}
h := &testServer{sh}
for _, endpoint := range NewTestEndpoints() {
opts = append(opts, micro_api.WithEndpoint(endpoint))
opts = append(opts, api.WithEndpoint(endpoint))
}
return s.Handle(s.NewHandler(&Test{h}, opts...))
}