Browse Source

Add decode of base64 string from GitHub webhook

After debugging, it's evident that GitHub delivers
base64-encoded strings for its payloads.
master
Matei-Alexandru Gardus 8 months ago
parent
commit
e100982fda
No known key found for this signature in database
1 changed files with 3 additions and 1 deletions
  1. 3
    1
      server/routes.go

+ 3
- 1
server/routes.go View File

@@ -2,6 +2,7 @@ package server
2 2
 
3 3
 import (
4 4
 	"bytes"
5
+	"encoding/base64"
5 6
 	"fmt"
6 7
 	"io/ioutil"
7 8
 	"net/http"
@@ -31,7 +32,8 @@ func (s *Server) handleGitHubHook() http.HandlerFunc {
31 32
 		}
32 33
 
33 34
 		eventType := r.Header.Get("X-GitHub-Event")
34
-		body, err := ioutil.ReadAll(r.Body)
35
+		body, _ := ioutil.ReadAll(r.Body)
36
+		decodedBody, err := base64.StdEncoding.DecodeString(body)
35 37
 		if err != nil {
36 38
 			w.WriteHeader(http.StatusInternalServerError)
37 39
 			fmt.Fprint(w, "Can't read body")

Loading…
Cancel
Save