Skip to content

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

@tqqq

Description

@tqqq

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的模版也有类似的问题

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions