stop using deprecated ioutil

This commit is contained in:
Akbar Rahman 2023-10-28 21:47:35 +01:00
parent 0f8b4d2e1e
commit e74c3a684e
Signed by: alvierahman90
GPG Key ID: 20609519444A1269

View File

@ -7,7 +7,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"log" "log"
"net/http" "net/http"
"os" "os"
@ -32,7 +31,7 @@ func main() {
checkSignature = p != "true" checkSignature = p != "true"
} }
raw_config, err := ioutil.ReadFile(config_filename) raw_config, err := os.ReadFile(config_filename)
if err != nil { if err != nil {
panic(err.Error()) panic(err.Error())
} }
@ -61,7 +60,7 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) {
// Read payload or return 500 if that doesn't work out // Read payload or return 500 if that doesn't work out
payload := "" payload := ""
if p, err := ioutil.ReadAll(r.Body); err != nil { if p, err := io.ReadAll(r.Body); err != nil {
writeResponse(w, 500, "Internal Server Error: Could not read payload") writeResponse(w, 500, "Internal Server Error: Could not read payload")
fmt.Println("Error: Could not read payload") fmt.Println("Error: Could not read payload")
return return