mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 09:00:20 +08:00
(goctl): fix prefix syntax (#4113)
This commit is contained in:
parent
04116f647d
commit
a9d27cda8a
@ -1247,6 +1247,34 @@ func (p *Parser) parseAtServerKVExpression() *ast.KVExpr {
|
||||
}
|
||||
}
|
||||
|
||||
valueTok.Type = token.PATH
|
||||
node := ast.NewTokenNode(valueTok)
|
||||
node.SetLeadingCommentGroup(leadingCommentGroup)
|
||||
expr.Value = node
|
||||
return expr
|
||||
} else if p.peekTokenIs(token.SUB) {
|
||||
for {
|
||||
if p.peekTokenIs(token.SUB) {
|
||||
if !p.nextToken() {
|
||||
return nil
|
||||
}
|
||||
|
||||
subTok := p.curTok
|
||||
if !p.advanceIfPeekTokenIs(token.IDENT) {
|
||||
return nil
|
||||
}
|
||||
|
||||
idTok := p.curTok
|
||||
valueTok = token.Token{
|
||||
Text: valueTok.Text + subTok.Text + idTok.Text,
|
||||
Position: valueTok.Position,
|
||||
}
|
||||
leadingCommentGroup = p.curTokenNode().LeadingCommentGroup
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
valueTok.Type = token.PATH
|
||||
node := ast.NewTokenNode(valueTok)
|
||||
node.SetLeadingCommentGroup(leadingCommentGroup)
|
||||
|
@ -303,6 +303,7 @@ func TestParser_Parse_atServerStmt(t *testing.T) {
|
||||
"prefix1:": "/v1/v2_test/v2-beta",
|
||||
"prefix2:": "v1/v2_test/v2-beta",
|
||||
"prefix3:": "v1/v2_",
|
||||
"prefix4:": "a-b-c",
|
||||
"summary:": `"test"`,
|
||||
}
|
||||
|
||||
|
@ -17,5 +17,6 @@
|
||||
prefix1: /v1/v2_test/v2-beta
|
||||
prefix2: v1/v2_test/v2-beta
|
||||
prefix3: v1/v2_
|
||||
prefix4: a-b-c
|
||||
summary:"test"
|
||||
)
|
||||
|
@ -180,12 +180,14 @@ service example {
|
||||
post /example/array/base (DemoOfArrayReq) returns ([]string)
|
||||
}
|
||||
|
||||
@server (
|
||||
group: /prefix
|
||||
prefix: foo-bar
|
||||
summary: "test"
|
||||
)
|
||||
service example {
|
||||
@handler nestDemo1
|
||||
post /example/nest (NestDemoReq1) returns (NestDemoResp1)
|
||||
|
||||
@handler nestDemo2
|
||||
post /example/nest2 (NestDemoReq2) returns (NestDemoResp2)
|
||||
@handler prefixDemo
|
||||
post /example/prefix (PostFormReq) returns (PostFormResp)
|
||||
}
|
||||
|
||||
@server (
|
||||
|
Loading…
Reference in New Issue
Block a user