Skip to content

Commit

Permalink
fix:duplicate route check (zeromicro#2154)
Browse files Browse the repository at this point in the history
Co-authored-by: 黄志荣 <huangzhirong@shuinfo.com>
  • Loading branch information
2 people authored and kevwan committed Jul 24, 2022
1 parent 28a3e61 commit 8117036
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tools/goctl/api/parser/g4/ast/apiparser.go
Expand Up @@ -232,20 +232,27 @@ func (p *Parser) invoke(linePrefix, content string) (v *Api, err error) {

// storeVerificationInfo stores information for verification
func (p *Parser) storeVerificationInfo(api *Api) {
routeMap := func(list []*ServiceRoute) {
routeMap := func(list []*ServiceRoute, prefix string) {
for _, g := range list {
handler := g.GetHandler()
if handler.IsNotNil() {
handlerName := handler.Text()
p.handlerMap[handlerName] = Holder
route := fmt.Sprintf("%s://%s", g.Route.Method.Text(), g.Route.Path.Text())
route := fmt.Sprintf("%s://%s", g.Route.Method.Text(), path.Join(prefix, g.Route.Path.Text()))
p.routeMap[route] = Holder
}
}
}

for _, each := range api.Service {
routeMap(each.ServiceApi.ServiceRoute)
var prefix string
if each.AtServer != nil {
pExp := each.AtServer.Kv.Get(prefixKey)
if pExp != nil {
prefix = pExp.Text()
}
}
routeMap(each.ServiceApi.ServiceRoute, prefix)
}

for _, each := range api.Type {
Expand Down

0 comments on commit 8117036

Please sign in to comment.