code: func (s *Server) RequireBasicAuth(logger log.Logger,
  	handler HandlerFunc, auth AuthFunc) HandlerFunc {
  	l := logger.Add("method", "RequireBasicAuth")
  	return func(w http.ResponseWriter, r *http.Request, ctx *Context) {
  		name, pass, ok := r.BasicAuth()
  		if !ok || !auth(name, pass) {
  			l.Add("sender", r.RemoteAddr).Warn("access denied")
  			s.RespondError(logger, w, ErrAccessDenied)
  			return
  		}
  
  		ctx.Username = name
  		handler(w, r, ctx)
  	}
  }
docs: // RequireBasicAuth wraps a given handler function inside a handler with basic
  // access authentication.