Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文档中middleware.go默认模版和源代码不一致 #1220

Open
tqqq opened this issue Jan 23, 2025 · 1 comment
Open

文档中middleware.go默认模版和源代码不一致 #1220

tqqq opened this issue Jan 23, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@tqqq
Copy link

tqqq commented Jan 23, 2025

What needs to be changed? Describe the update that is required.
文档中middleware.go默认模版和源代码不一致

What is the name + path of the page that needs changed? The relative path
and page title where you found a problem.
这是cloudwego中middleware.go的模版:

      {{define "M"}}
      func {{.MiddleWare}}Mw() []app.HandlerFunc {
      	// your code...
      	return nil
      }
      {{range $_, $router := $.Children}}{{template "M" $router}}{{end}}
      {{- end}}

      {{template "M" .Router}}  

这是Hertz源码中的默认模版:


{{define "M"}}
{{- if ne .Children.Len 0}}
func {{.GroupMiddleware}}Mw() []app.HandlerFunc {
	// your code...
	return nil
}
{{end}}
{{- if ne .Handler ""}}
func {{.HandlerMiddleware}}Mw() []app.HandlerFunc {
	// your code...
	return nil
}
{{end}}
{{range $_, $router := $.Children}}{{template "M" $router}}{{end}}
{{- end}}

{{template "M" .Router}}

router.go的模版也有类似的问题

@tqqq tqqq added the bug Something isn't working label Jan 23, 2025
@FGYFFFF
Copy link
Contributor

FGYFFFF commented Jan 23, 2025

@tqqq 模板后面路由都有一些更新,文档中没有及时更新,你可以提个 pr 帮忙改下吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants