mirror of
https://github.com/go-micro/go-micro.git
synced 2025-07-12 22:41:07 +02:00
minor changes
This commit is contained in:
@ -39,7 +39,7 @@ type registryRouter struct {
|
|||||||
ceps map[string]*endpoint
|
ceps map[string]*endpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *registryRouter) isStopd() bool {
|
func (r *registryRouter) isStopped() bool {
|
||||||
select {
|
select {
|
||||||
case <-r.exit:
|
case <-r.exit:
|
||||||
return true
|
return true
|
||||||
@ -225,7 +225,7 @@ func (r *registryRouter) watch() {
|
|||||||
var attempts int
|
var attempts int
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if r.isStopd() {
|
if r.isStopped() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ func (r *registryRouter) Deregister(ep *router.Route) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *registryRouter) Endpoint(req *http.Request) (*router.Route, error) {
|
func (r *registryRouter) Endpoint(req *http.Request) (*router.Route, error) {
|
||||||
if r.isStopd() {
|
if r.isStopped() {
|
||||||
return nil, errors.New("router closed")
|
return nil, errors.New("router closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +373,6 @@ func (r *registryRouter) Endpoint(req *http.Request) (*router.Route, error) {
|
|||||||
for k, v := range matches {
|
for k, v := range matches {
|
||||||
md[fmt.Sprintf("x-api-field-%s", k)] = v
|
md[fmt.Sprintf("x-api-field-%s", k)] = v
|
||||||
}
|
}
|
||||||
md["x-api-body"] = ep.Body
|
|
||||||
*req = *req.Clone(metadata.NewContext(ctx, md))
|
*req = *req.Clone(metadata.NewContext(ctx, md))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -409,7 +408,7 @@ func (r *registryRouter) Endpoint(req *http.Request) (*router.Route, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *registryRouter) Route(req *http.Request) (*router.Route, error) {
|
func (r *registryRouter) Route(req *http.Request) (*router.Route, error) {
|
||||||
if r.isStopd() {
|
if r.isStopped() {
|
||||||
return nil, errors.New("router closed")
|
return nil, errors.New("router closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ type Route struct {
|
|||||||
type Endpoint struct {
|
type Endpoint struct {
|
||||||
// RPC Method e.g. Greeter.Hello
|
// RPC Method e.g. Greeter.Hello
|
||||||
Name string
|
Name string
|
||||||
// Description e.g what's this endpoint for
|
// What the endpoint is for
|
||||||
Description string
|
Description string
|
||||||
// API Handler e.g rpc, proxy
|
// API Handler e.g rpc, proxy
|
||||||
Handler string
|
Handler string
|
||||||
@ -44,10 +44,6 @@ type Endpoint struct {
|
|||||||
Method []string
|
Method []string
|
||||||
// HTTP Path e.g /greeter. Expect POSIX regex
|
// HTTP Path e.g /greeter. Expect POSIX regex
|
||||||
Path []string
|
Path []string
|
||||||
// Body destination
|
|
||||||
// "*" or "" - top level message value
|
|
||||||
// "string" - inner message value
|
|
||||||
Body string
|
|
||||||
// Stream flag
|
// Stream flag
|
||||||
Stream bool
|
Stream bool
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,6 @@ func (r *staticRouter) Endpoint(req *http.Request) (*router.Route, 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,
|
||||||
Body: ep.apiep.Body,
|
|
||||||
Stream: ep.apiep.Stream,
|
Stream: ep.apiep.Stream,
|
||||||
},
|
},
|
||||||
Versions: services,
|
Versions: services,
|
||||||
@ -299,7 +298,6 @@ func (r *staticRouter) endpoint(req *http.Request) (*endpoint, error) {
|
|||||||
for k, v := range matches {
|
for k, v := range matches {
|
||||||
md[fmt.Sprintf("x-api-field-%s", k)] = v
|
md[fmt.Sprintf("x-api-field-%s", k)] = v
|
||||||
}
|
}
|
||||||
md["x-api-body"] = ep.apiep.Body
|
|
||||||
*req = *req.Clone(metadata.NewContext(ctx, md))
|
*req = *req.Clone(metadata.NewContext(ctx, md))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user