Move host to a env variable and combine host/port to address var for HTTP server

This commit is contained in:
Sebastian Cabrera 2023-08-28 23:51:15 -04:00
parent 7eee357aad
commit 6c288c4bf6

View file

@ -6,6 +6,7 @@ import (
"github.com/google/go-github/v54/github" "github.com/google/go-github/v54/github"
"golang.org/x/net/context" "golang.org/x/net/context"
"log" "log"
"net"
"net/http" "net/http"
"os" "os"
"strconv" "strconv"
@ -14,6 +15,7 @@ import (
// Wrap the shared transport for use with the integration ID and authenticating with installation ID. // Wrap the shared transport for use with the integration ID and authenticating with installation ID.
var privateKey = os.Getenv("privateKey") var privateKey = os.Getenv("privateKey")
var host = os.Getenv("host")
var port = os.Getenv("port") var port = os.Getenv("port")
var itr, _ = ghinstallation.New(http.DefaultTransport, 381312, 41105280, []byte(privateKey)) var itr, _ = ghinstallation.New(http.DefaultTransport, 381312, 41105280, []byte(privateKey))
@ -45,7 +47,9 @@ func listenForWebhook() {
http.HandleFunc("/", webHandle) http.HandleFunc("/", webHandle)
http.HandleFunc("/webhook", webhookHandler) http.HandleFunc("/webhook", webhookHandler)
err := http.ListenAndServe(port, nil) address := net.JoinHostPort(host, port)
err := http.ListenAndServe(address, nil)
if err != nil { if err != nil {
panic(err) panic(err)
} }