if the service name is blank, barf

This commit is contained in:
Asim Aslam 2019-08-29 13:10:06 +01:00
parent b3aef71fdb
commit 7d033818cf

View File

@ -161,9 +161,6 @@ func (p *Proxy) manageRouteCache(route router.Route, action string) error {
} }
p.Routes[route.Service][route.Hash()] = route p.Routes[route.Service][route.Hash()] = route
case "delete": case "delete":
if _, ok := p.Routes[route.Service]; !ok {
return fmt.Errorf("route not found")
}
delete(p.Routes[route.Service], route.Hash()) delete(p.Routes[route.Service], route.Hash())
default: default:
return fmt.Errorf("unknown action: %s", action) return fmt.Errorf("unknown action: %s", action)
@ -219,6 +216,11 @@ func (p *Proxy) ServeRequest(ctx context.Context, req server.Request, rsp server
// endpoint to call // endpoint to call
endpoint := req.Endpoint() endpoint := req.Endpoint()
if len(service) == 0 {
b, _ := req.Read()
return errors.BadRequest("go.micro.proxy", "service name is blank")
}
// are we network routing or local routing // are we network routing or local routing
if len(p.Links) == 0 { if len(p.Links) == 0 {
local = true local = true