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 10 months ago
parent
commit
e100982fda
Signed by: StormFireFox1 <matei@gardus.eu> GPG Key ID: F3D2B830AB9B94AA
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

import (
"bytes"
"encoding/base64"
"fmt"
"io/ioutil"
"net/http"
@@ -31,7 +32,8 @@ func (s *Server) handleGitHubHook() http.HandlerFunc {
}

eventType := r.Header.Get("X-GitHub-Event")
body, err := ioutil.ReadAll(r.Body)
body, _ := ioutil.ReadAll(r.Body)
decodedBody, err := base64.StdEncoding.DecodeString(body)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprint(w, "Can't read body")

Loading…
Cancel
Save