func Validate(w http.ResponseWriter, r *http.Request) error {
	var err error
	auth := r.Header.Get("Authorization")
	if auth == "" {
		w.Header().Set("WWW-Authenticate", `Bearer realm="Datadog Agent"`)
		err = fmt.Errorf("no session token provided")
		http.Error(w, err.Error(), 401)
		return err
	}

	tok := strings.Split(auth, " ")
	if tok[0] != "Bearer" {
		w.Header().Set("WWW-Authenticate", `Bearer realm="Datadog Agent"`)
		err = fmt.Errorf("unsupported authorization scheme: %s", tok[0])
		http.Error(w, err.Error(), 401)
		return err
	}

	if len(tok) < 2 || tok[1] != GetAuthToken() {
		err = fmt.Errorf("invalid session token")
		http.Error(w, err.Error(), 403)
	}

	return err
}
// Validate validates an http request
Validate validates an http request
// Validate validates an http request
func Validate(w http.ResponseWriter, r *http.Request) error {
	var err error
	auth := r.Header.Get("Authorization")
	if auth == "" {
		w.Header().Set("WWW-Authenticate", `Bearer realm="Datadog Agent"`)
		err = fmt.Errorf("no session token provided")
		http.Error(w, err.Error(), 401)
		return err
	}
	tok := strings.Split(auth, " ")
	if tok[0] != "Bearer" {
		w.Header().Set("WWW-Authenticate", `Bearer realm="Datadog Agent"`)
		err = fmt.Errorf("unsupported authorization scheme: %s", tok[0])
		http.Error(w, err.Error(), 401)
		return err
	}
	if len(tok) < 2 || tok[1] != GetAuthToken() {
		err = fmt.Errorf("invalid session token")
		http.Error(w, err.Error(), 403)
	}
	return err
}
func Validate ( w http . ResponseWriter , r * http . Request ) error { var err error auth := r . Header . Get ( " " ) if auth == " " { w . Header ( ) . Set ( " " , `Bearer realm="Datadog Agent"` ) err = fmt . Errorf ( " " ) http . Error ( w , err . Error ( ) , 401 ) return err } tok := strings . Split ( auth , " " ) if tok [ 0 ] != " " { w . Header ( ) . Set ( " " , `Bearer realm="Datadog Agent"` ) err = fmt . Errorf ( " " , tok [ 0 ] ) http . Error ( w , err . Error ( ) , 401 ) return err } if len ( tok ) < 2 || tok [ 1 ] != GetAuthToken ( ) { err = fmt . Errorf ( " " ) http . Error ( w , err . Error ( ) , 403 ) } return err }
Validate validates an http request
Validate validates an http request