Skip to content

Commit

Permalink
add /v1/email/<email>/key.asc endpoint
Browse files Browse the repository at this point in the history
So I can finally redirect paulfurley.com/pgp to it :)
  • Loading branch information
Paul Fawkesley committed Jan 9, 2019
1 parent ae5624e commit f7bf273
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions server/keyshandler.go
Expand Up @@ -21,6 +21,22 @@ import (
"github.com/gorilla/mux"
)

func getAsciiArmoredPublicKeyHandler(w http.ResponseWriter, r *http.Request) {
email := mux.Vars(r)["email"]

armoredPublicKey, found, err := datastore.GetArmoredPublicKeyForEmail(nil, email)
if err != nil {
writeJsonError(w, err, http.StatusInternalServerError)
return
} else if !found {
w.WriteHeader(http.StatusNotFound)
fmt.Fprintf(w, "Key not found for %s", email)
return
}

fmt.Fprintf(w, armoredPublicKey)
}

func getPublicKeyHandler(w http.ResponseWriter, r *http.Request) {
email := mux.Vars(r)["email"]

Expand Down
1 change: 1 addition & 0 deletions server/server.go
Expand Up @@ -21,6 +21,7 @@ func init() {
subrouter.HandleFunc("/email/verify/{uuid:"+uuid4Pattern+"}", verifyEmailHandler).Methods("GET", "POST")

subrouter.HandleFunc("/email/{email}/key", getPublicKeyHandler).Methods("GET")
subrouter.HandleFunc("/email/{email}/key.asc", getAsciiArmoredPublicKeyHandler).Methods("GET")
subrouter.HandleFunc("/keys", upsertPublicKeyHandler).Methods("POST")

subrouter.HandleFunc("/secrets", sendSecretHandler).Methods("POST")
Expand Down

0 comments on commit f7bf273

Please sign in to comment.