Last active
May 7, 2019 11:58
-
-
Save cyantarek/3c83951f1a66d43abd4a89a83117e40a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http.HandleFunc("/credentials", func(w http.ResponseWriter, r *http.Request) { | |
domain := r.Header.Get("DOMAIN") | |
if domain == "" { | |
http.Error(w, "domain missing", 500) | |
return | |
} | |
clientId := genKey() | |
clientSecret := genKey() | |
err := clientStore.Set(clientId, &models.Client{ | |
ID: clientId, | |
Secret: clientSecret, | |
Domain: domain, | |
}) | |
if err != nil { | |
http.Error(w, err.Error(), 500) | |
return | |
} | |
w.Header().Set("Content-Type", "application/json") | |
_ = json.NewEncoder(w).Encode(map[string]string{"client_id": clientId, "client_secret": clientSecret}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment