server, examples, extensions lint compliant (#1109)

these are all automated changes suggested by golint
This commit is contained in:
Reed Allman
2018-07-04 09:23:15 -05:00
committed by Owen Cliffe
parent 6f5e58144a
commit 1cdb47d6e9
30 changed files with 355 additions and 223 deletions

View File

@@ -25,15 +25,14 @@ func main() {
})
})
funcServer.AddMiddleware(&CustomMiddleware{})
funcServer.AddMiddleware(&customMiddleware{})
funcServer.Start(ctx)
}
type CustomMiddleware struct {
}
type customMiddleware struct{}
func (h *CustomMiddleware) Handle(next http.Handler) http.Handler {
func (h *customMiddleware) Handle(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Println("CustomMiddleware called")
@@ -48,7 +47,9 @@ func (h *CustomMiddleware) Handle(next http.Handler) http.Handler {
return
}
fmt.Println("auth succeeded!")
r = r.WithContext(context.WithValue(r.Context(), "user", "I'm in!"))
r = r.WithContext(context.WithValue(r.Context(), contextKey("user"), "I'm in!"))
next.ServeHTTP(w, r)
})
}
type contextKey string