Skip to content

E0710: A folder's Middleware is malformed ​

A folder's Middleware wraps every page, page method handler and endpoint in its folder and below, root-first. It is a package-level function of one of two forms: func Middleware(next http.Handler) http.Handler, or a constructor func Middleware(deps…) web.Middleware whose dependencies the container provides. Reported at the function.

Wrong ​

go
package api

func Middleware(next http.Handler) error { … }
go
package api

func Middleware(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("X-API", "1")
		next.ServeHTTP(w, r)
	})
}

Released under the MIT License. Vuka builds on Go and its tools, which are made by the Go Authors. Vuka is not affiliated with Google or the Go project. Go is a trademark of Google LLC.