Exemple #1
0
func (v *APIKeyValidator) Handle(w http.ResponseWriter, r *vertex.Request, next vertex.HandlerFunc) (interface{}, error) {

	if _, found := v.validKeys[r.FormValue(v.paramName)]; !found {
		return nil, vertex.UnauthorizedError("missing or invalid api key '%s'", r.FormValue(v.paramName))
	}

	return next(w, r)

}
Exemple #2
0
func APIKeyValidator(r *vertex.Request) error {
	if r.FormValue("apiKey") != config.APIKey {
		return vertex.UnauthorizedError("Inalid API key")
	}
	return nil
}