mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-14 02:10:00 +08:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user