-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathwebhook.go
More file actions
30 lines (27 loc) · 666 Bytes
/
webhook.go
File metadata and controls
30 lines (27 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package keygen
import (
"net/http"
)
// VerifyWebhook verifies the signature of a webhook request sent from
// Keygen. The webhook event should be considered invalid if an error
// is returned.
//
// Example:
//
// func main() {
// http.HandleFunc("/webhooks", func(w http.ResponseWriter, r *http.Request) {
// if err := keygen.VerifyWebhook(r); err != nil {
// w.WriteHeader(http.StatusBadRequest)
//
// return
// }
//
// w.WriteHeader(http.StatusNoContent)
// })
//
// http.ListenAndServe(":8081", nil)
// }
func VerifyWebhook(request *http.Request) error {
verifier := &verifier{PublicKey: PublicKey}
return verifier.VerifyRequest(request)
}