Skip to content

Commit

Permalink
Autofix for finding 01J0HQ0A7GG1STVT9074R18TMZ
Browse files Browse the repository at this point in the history
  • Loading branch information
j2nullify committed Oct 4, 2024
1 parent 27af3ec commit b5e2e42
Show file tree
Hide file tree
Showing 3 changed files with 442 additions and 4 deletions.
22 changes: 18 additions & 4 deletions _examples/single-handler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"fmt"

"net/http"
"time"

"github.com/go-playground/webhooks/v6/github"
)
Expand All @@ -15,11 +15,12 @@ const (
func main() {
hook, _ := github.New(github.Options.Secret("MyGitHubSuperSecretSecrect...?"))

http.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
mux := http.NewServeMux()
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
payload, err := hook.Parse(r, github.ReleaseEvent, github.PullRequestEvent)
if err != nil {
if err == github.ErrEventNotFound {
// ok event wasn;t one of the ones asked to be parsed
// ok event wasn't one of the ones asked to be parsed
}
}
switch payload.(type) {
Expand All @@ -35,5 +36,18 @@ func main() {
fmt.Printf("%+v", pullRequest)
}
})
http.ListenAndServe(":3000", nil)

server := &http.Server{
Addr: ":3000",
Handler: mux,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 120 * time.Second,
}

fmt.Println("Server is starting on port 3000...")
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
fmt.Printf("Error starting server: %s
", err)
}
}
Loading

0 comments on commit b5e2e42

Please sign in to comment.