File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ func frontend(w http.ResponseWriter, r *http.Request) {
6060 hook := github.Hook {
6161 Name : & name , Events : []string {"pull_request" },
6262 Config : map [string ]interface {}{
63+ "content_type" : "json" ,
6364 "url" : serverDomain + "/hook" ,
6465 "secret" : secret ,
6566 },
@@ -80,8 +81,15 @@ func frontend(w http.ResponseWriter, r *http.Request) {
8081 return
8182 }
8283
83- fmt .Fprintf (w , `Success :) You can undo it by simply deleting the
84- <a href="https://github.com/%s/settings/hooks">webhook</a>.` , repo )
84+ fmt .Fprintf (w , `<!DOCTYPE html>
85+ <html>
86+ <body>
87+ <p>
88+ Success :) You can undo it by simply deleting the
89+ <a href="https://github.com/%s/settings/hooks">webhook</a>.
90+ </p>
91+ </body>
92+ </html>` , repo )
8593 return
8694 }
8795
Original file line number Diff line number Diff line change @@ -36,12 +36,14 @@ func webhook(w http.ResponseWriter, r *http.Request) {
3636
3737 var event github.PullRequestReviewEvent
3838 err = json .Unmarshal (b , & event )
39- if err != nil {
39+ pr := event .PullRequest
40+ if err != nil || pr == nil {
4041 logger .Println ("Not supported event type" , string (b ))
4142 fmt .Fprintf (w , `{"error":"unsupported event type"}` )
4243 return
4344 }
44- pr := event .PullRequest
45+
46+ // skip all events except for open PRs
4547 if * pr .State != "open" {
4648 logger .Println ("Ignore closed pull request" )
4749 fmt .Fprintf (w , `{}` )
You can’t perform that action at this time.
0 commit comments