Cli (#1272)
* Fix issue 1260 (#1262) * Fix #1238 (#1266) * docs: update readme to use goctl@cli (#1255) * chore: update goctl version * style: coding style * docs: update readme to use goctl@cli * fix #1238 * format code * format code Co-authored-by: Kevin Wan <wanjunfeng@gmail.com> Co-authored-by: anqiansong <anqiansong@bytedance.com> Co-authored-by: anqiansong <anqiansong@gmail.com> Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
@@ -2,11 +2,14 @@ package ast
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"sort"
|
||||
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/parser/g4/gen/api"
|
||||
)
|
||||
|
||||
const prefixKey = "prefix"
|
||||
|
||||
// Api describes syntax for api
|
||||
type Api struct {
|
||||
LinePrefix string
|
||||
@@ -49,8 +52,15 @@ func (v *ApiVisitor) acceptService(root, final *Api) {
|
||||
}
|
||||
v.duplicateServerItemCheck(service)
|
||||
|
||||
var prefix string
|
||||
if service.AtServer != nil {
|
||||
p := service.AtServer.Kv.Get(prefixKey)
|
||||
if p != nil {
|
||||
prefix = p.Text()
|
||||
}
|
||||
}
|
||||
for _, route := range service.ServiceApi.ServiceRoute {
|
||||
uniqueRoute := fmt.Sprintf("%s %s", route.Route.Method.Text(), route.Route.Path.Text())
|
||||
uniqueRoute := fmt.Sprintf("%s %s", route.Route.Method.Text(), path.Join(prefix, route.Route.Path.Text()))
|
||||
if _, ok := final.routeM[uniqueRoute]; ok {
|
||||
v.panic(route.Route.Method, fmt.Sprintf("duplicate route '%s'", uniqueRoute))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user