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:
		
							
								
								
									
										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/logger" | ||||
| 	"github.com/micro/go-micro/v2/metadata" | ||||
| 	"github.com/micro/go-micro/v2/registry" | ||||
| ) | ||||
|  | ||||
| type endpoint struct { | ||||
| @@ -163,13 +164,23 @@ func (r *staticRouter) Endpoint(req *http.Request) (*api.Service, error) { | ||||
|  | ||||
| 	// hack for stream endpoint | ||||
| 	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 { | ||||
| 				e.Name = strings.Join(epf[1:], ".") | ||||
| 				e.Metadata = make(map[string]string) | ||||
| 				e.Metadata["stream"] = "true" | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		services = svcs | ||||
| 	} | ||||
|  | ||||
| 	svc := &api.Service{ | ||||
| @@ -180,6 +191,7 @@ func (r *staticRouter) Endpoint(req *http.Request) (*api.Service, error) { | ||||
| 			Host:    ep.apiep.Host, | ||||
| 			Method:  ep.apiep.Method, | ||||
| 			Path:    ep.apiep.Path, | ||||
| 			Stream:  ep.apiep.Stream, | ||||
| 		}, | ||||
| 		Services: services, | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user