regen and update

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-06-30 17:53:06 +03:00
parent 14d062b4a5
commit 3ceff22f52
28 changed files with 1333 additions and 60 deletions

View File

@@ -2,4 +2,4 @@ package http
//go:generate protoc -I./proto -I. -I/home/vtolstov/devel/projects/unistack/micro/micro-proto --go_out=paths=source_relative:./proto proto/test.proto
//go:generate protoc -I./proto -I. -I/home/vtolstov/devel/projects/unistack/micro/micro-proto --micro_out=components=micro|http,debug=true,tag_path=./proto,paths=source_relative:./proto proto/test.proto
//go:generate protoc -I./proto -I. -I/home/vtolstov/devel/projects/unistack/micro/micro-proto --go-micro_out=components=micro|http,debug=true,tag_path=./proto,paths=source_relative:./proto proto/test.proto

View File

@@ -16,6 +16,7 @@ import (
jsoncodec "github.com/unistack-org/micro-codec-json/v3"
jsonpbcodec "github.com/unistack-org/micro-codec-jsonpb/v3"
urlencodecodec "github.com/unistack-org/micro-codec-urlencode/v3"
xmlcodec "github.com/unistack-org/micro-codec-xml/v3"
vmeter "github.com/unistack-org/micro-meter-victoriametrics/v3"
httpsrv "github.com/unistack-org/micro-server-http/v3"
pb "github.com/unistack-org/micro-tests/server/http/proto"
@@ -143,10 +144,19 @@ func NewServerHandlerWrapper(t *testing.T) server.HandlerWrapper {
}
nmd := metadata.New(1)
nmd.Set("my-key", "my-val")
nmd.Set("Content-Type", "text/xml")
metadata.SetOutgoingContext(ctx, nmd)
httpsrv.SetRspCode(ctx, http.StatusUnauthorized)
return httpsrv.SetError(&pb.CallRsp{Rsp: "name_my_name"})
}
if v, ok := md.Get("Test-Content-Type"); ok && v != "" {
nmd := metadata.New(1)
nmd.Set("my-key", "my-val")
nmd.Set("Content-Type", v)
metadata.SetOutgoingContext(ctx, nmd)
}
return fn(ctx, req, rsp)
}
}
@@ -470,6 +480,7 @@ func TestNativeServer(t *testing.T) {
srv := httpsrv.NewServer(
server.Name("helloworld"),
server.Register(reg),
server.Codec("text/xml", xmlcodec.NewCodec()),
server.Codec("application/json", jsoncodec.NewCodec()),
server.Codec("application/x-www-form-urlencoded", urlencodecodec.NewCodec()),
server.WrapHandler(NewServerHandlerWrapper(t)),
@@ -594,6 +605,8 @@ func TestNativeServer(t *testing.T) {
t.Fatalf("invalid rsp received: %#+v\n", rsp)
}
// Test-Content-Type
// stop server
if err := srv.Stop(); err != nil {
t.Fatal(err)

View File

@@ -1,5 +1,7 @@
// Code generated by protoc-gen-micro
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// protoc-gen-go-micro version: v3.4.0
// source: test.proto
package pb
import (
@@ -8,9 +10,9 @@ import (
client "github.com/unistack-org/micro/v3/client"
)
func NewTestDoubleEndpoints() []*api.Endpoint {
return []*api.Endpoint{
&api.Endpoint{
var (
TestDoubleEndpoints = []api.Endpoint{
api.Endpoint{
Name: "TestDouble.CallDouble",
Path: []string{"/v1/testdouble/call/{name}"},
Method: []string{"POST"},
@@ -18,6 +20,10 @@ func NewTestDoubleEndpoints() []*api.Endpoint {
Handler: "rpc",
},
}
)
func NewTestDoubleEndpoints() []api.Endpoint {
return TestDoubleEndpoints
}
type TestDoubleClient interface {
@@ -28,30 +34,30 @@ type TestDoubleServer interface {
CallDouble(ctx context.Context, req *CallReq, rsp *CallRsp) error
}
func NewTestEndpoints() []*api.Endpoint {
return []*api.Endpoint{
&api.Endpoint{
var (
TestEndpoints = []api.Endpoint{
api.Endpoint{
Name: "Test.CallRepeatedString",
Path: []string{"/v1/test/call_repeated_string/{string_ids}"},
Method: []string{"POST"},
Body: "*",
Handler: "rpc",
},
&api.Endpoint{
api.Endpoint{
Name: "Test.CallRepeatedInt64",
Path: []string{"/v1/test/call_repeated_int64/{int64_ids}"},
Method: []string{"POST"},
Body: "*",
Handler: "rpc",
},
&api.Endpoint{
api.Endpoint{
Name: "Test.Call",
Path: []string{"/v1/test/call/{name}"},
Method: []string{"POST"},
Body: "*",
Handler: "rpc",
},
&api.Endpoint{
api.Endpoint{
Name: "Test.CallError",
Path: []string{"/v1/test/callerror/{name}"},
Method: []string{"POST"},
@@ -59,6 +65,10 @@ func NewTestEndpoints() []*api.Endpoint {
Handler: "rpc",
},
}
)
func NewTestEndpoints() []api.Endpoint {
return TestEndpoints
}
type TestClient interface {

View File

@@ -1,5 +1,7 @@
// Code generated by protoc-gen-micro
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// protoc-gen-go-micro version: v3.4.0
// source: test.proto
package pb
import (
@@ -61,8 +63,8 @@ func RegisterTestDoubleServer(s server.Server, sh TestDoubleServer, opts ...serv
}
h := &testDoubleServer{sh}
var nopts []server.HandlerOption
for _, endpoint := range NewTestDoubleEndpoints() {
nopts = append(nopts, api.WithEndpoint(endpoint))
for _, endpoint := range TestDoubleEndpoints {
nopts = append(nopts, api.WithEndpoint(&endpoint))
}
return s.Handle(s.NewHandler(&TestDouble{h}, append(nopts, opts...)...))
}
@@ -196,8 +198,8 @@ func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOp
}
h := &testServer{sh}
var nopts []server.HandlerOption
for _, endpoint := range NewTestEndpoints() {
nopts = append(nopts, api.WithEndpoint(endpoint))
for _, endpoint := range TestEndpoints {
nopts = append(nopts, api.WithEndpoint(&endpoint))
}
return s.Handle(s.NewHandler(&Test{h}, append(nopts, opts...)...))
}