1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-30 10:10:44 +02:00

minor changes

This commit is contained in:
Asim Aslam 2022-07-02 14:25:21 +01:00
parent e313863a2a
commit 63d1f9de4a
3 changed files with 5 additions and 12 deletions

View File

@ -39,7 +39,7 @@ type registryRouter struct {
ceps map[string]*endpoint
}
func (r *registryRouter) isStopd() bool {
func (r *registryRouter) isStopped() bool {
select {
case <-r.exit:
return true
@ -225,7 +225,7 @@ func (r *registryRouter) watch() {
var attempts int
for {
if r.isStopd() {
if r.isStopped() {
return
}
@ -293,7 +293,7 @@ func (r *registryRouter) Deregister(ep *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")
}
@ -373,7 +373,6 @@ func (r *registryRouter) Endpoint(req *http.Request) (*router.Route, error) {
for k, v := range matches {
md[fmt.Sprintf("x-api-field-%s", k)] = v
}
md["x-api-body"] = ep.Body
*req = *req.Clone(metadata.NewContext(ctx, md))
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) {
if r.isStopd() {
if r.isStopped() {
return nil, errors.New("router closed")
}

View File

@ -34,7 +34,7 @@ type Route struct {
type Endpoint struct {
// RPC Method e.g. Greeter.Hello
Name string
// Description e.g what's this endpoint for
// What the endpoint is for
Description string
// API Handler e.g rpc, proxy
Handler string
@ -44,10 +44,6 @@ type Endpoint struct {
Method []string
// HTTP Path e.g /greeter. Expect POSIX regex
Path []string
// Body destination
// "*" or "" - top level message value
// "string" - inner message value
Body string
// Stream flag
Stream bool
}

View File

@ -213,7 +213,6 @@ func (r *staticRouter) Endpoint(req *http.Request) (*router.Route, error) {
Host: ep.apiep.Host,
Method: ep.apiep.Method,
Path: ep.apiep.Path,
Body: ep.apiep.Body,
Stream: ep.apiep.Stream,
},
Versions: services,
@ -299,7 +298,6 @@ func (r *staticRouter) endpoint(req *http.Request) (*endpoint, error) {
for k, v := range matches {
md[fmt.Sprintf("x-api-field-%s", k)] = v
}
md["x-api-body"] = ep.apiep.Body
*req = *req.Clone(metadata.NewContext(ctx, md))
break
}