api/handler/rpc: binary streaming support (#1466)
* api/handler/rpc: binary streaming support Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * fixup Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * fix Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * fix sec webscoekt protol Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
5e8581146a
commit
b7b731fc79
14
static.go
14
static.go
@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/micro/go-micro/v2/api/router"
|
"github.com/micro/go-micro/v2/api/router"
|
||||||
"github.com/micro/go-micro/v2/logger"
|
"github.com/micro/go-micro/v2/logger"
|
||||||
"github.com/micro/go-micro/v2/metadata"
|
"github.com/micro/go-micro/v2/metadata"
|
||||||
|
"github.com/micro/go-micro/v2/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
type endpoint struct {
|
type endpoint struct {
|
||||||
@ -163,13 +164,23 @@ func (r *staticRouter) Endpoint(req *http.Request) (*api.Service, error) {
|
|||||||
|
|
||||||
// hack for stream endpoint
|
// hack for stream endpoint
|
||||||
if ep.apiep.Stream {
|
if ep.apiep.Stream {
|
||||||
for _, svc := range services {
|
svcs := registry.Copy(services)
|
||||||
|
for _, svc := range svcs {
|
||||||
|
if len(svc.Endpoints) == 0 {
|
||||||
|
e := ®istry.Endpoint{}
|
||||||
|
e.Name = strings.Join(epf[1:], ".")
|
||||||
|
e.Metadata = make(map[string]string)
|
||||||
|
e.Metadata["stream"] = "true"
|
||||||
|
svc.Endpoints = append(svc.Endpoints, e)
|
||||||
|
}
|
||||||
for _, e := range svc.Endpoints {
|
for _, e := range svc.Endpoints {
|
||||||
e.Name = strings.Join(epf[1:], ".")
|
e.Name = strings.Join(epf[1:], ".")
|
||||||
e.Metadata = make(map[string]string)
|
e.Metadata = make(map[string]string)
|
||||||
e.Metadata["stream"] = "true"
|
e.Metadata["stream"] = "true"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
services = svcs
|
||||||
}
|
}
|
||||||
|
|
||||||
svc := &api.Service{
|
svc := &api.Service{
|
||||||
@ -180,6 +191,7 @@ func (r *staticRouter) Endpoint(req *http.Request) (*api.Service, error) {
|
|||||||
Host: ep.apiep.Host,
|
Host: ep.apiep.Host,
|
||||||
Method: ep.apiep.Method,
|
Method: ep.apiep.Method,
|
||||||
Path: ep.apiep.Path,
|
Path: ep.apiep.Path,
|
||||||
|
Stream: ep.apiep.Stream,
|
||||||
},
|
},
|
||||||
Services: services,
|
Services: services,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user