Fix SSE handler generation to use correct template file

The issue was that SSE handlers were incorrectly using handler.tpl instead of sse_handler.tpl, causing the wrong handler pattern to be generated when custom templates were present. This fix ensures SSE handlers and logic use their dedicated template files (sse_handler.tpl and sse_logic.tpl) when SSE annotation is enabled.

Co-authored-by: kevwan <1918356+kevwan@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-10-07 03:31:50 +00:00
parent 59e9e54a21
commit 42b5713621
4 changed files with 165 additions and 19 deletions

View File

@@ -38,9 +38,11 @@ func genHandler(dir, rootPkg, projectPkg string, cfg *config.Config, group spec.
}
var builtinTemplate = handlerTemplate
var templateFile = handlerTemplateFile
sse := group.GetAnnotation("sse")
if sse == "true" {
builtinTemplate = sseHandlerTemplate
templateFile = sseHandlerTemplateFile
}
return genFile(fileGenConfig{
@@ -49,7 +51,7 @@ func genHandler(dir, rootPkg, projectPkg string, cfg *config.Config, group spec.
filename: filename + ".go",
templateName: "handlerTemplate",
category: category,
templateFile: handlerTemplateFile,
templateFile: templateFile,
builtinTemplate: builtinTemplate,
data: map[string]any{
"PkgName": pkgName,