(goctl)feature: supported sse generation (#5082)

Co-authored-by: Kevin Wan <wanjunfeng@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
kesonan
2025-08-15 09:49:50 +08:00
committed by GitHub
parent 3e6ec9b83d
commit 4bdb07f225
7 changed files with 141 additions and 9 deletions

View File

@@ -244,6 +244,7 @@ func (a *Analyzer) fillService() error {
group.Annotation.Properties = a.convertKV(item.AtServerStmt.Values)
}
sse := group.GetAnnotation("sse") == "true"
for _, astRoute := range item.Routes {
head, leading := astRoute.CommentGroup()
route := spec.Route{
@@ -277,6 +278,13 @@ func (a *Analyzer) fillService() error {
}
route.ResponseType = responseType
}
if route.ResponseType == nil && sse {
if route.RequestType != nil {
return ast.SyntaxError(astRoute.Route.Request.Pos(), "missing response type")
} else {
return ast.SyntaxError(astRoute.Route.Path.Pos(), "missing response type")
}
}
if err := a.fillRouteType(&route); err != nil {
return err