diff --git a/http.go b/http.go index c8019a3..d4cb736 100644 --- a/http.go +++ b/http.go @@ -2,12 +2,13 @@ package main import ( "encoding/json" + "errors" "io" "net/http" monobank "stuzer.link/monobank-firefly3-bot/monobank/api/webhook/models" ) -func readResponseBody(r *http.Request) (monobank.Transaction, error) { +func readRequestBody(r *http.Request) (monobank.Transaction, error) { // read body bytes body, err := io.ReadAll(r.Body) if err != nil { @@ -18,7 +19,7 @@ func readResponseBody(r *http.Request) (monobank.Transaction, error) { // check empty body if len(string(body)) == 0 { - return monobank.Transaction{}, err + return monobank.Transaction{}, errors.New("empty body") } // parse body diff --git a/webhook.go b/webhook.go index f631529..a25bba7 100644 --- a/webhook.go +++ b/webhook.go @@ -25,7 +25,7 @@ func handleWebhook(w http.ResponseWriter, r *http.Request) { // read request var monobankTransaction monobank.Transaction - monobankTransaction, err = readResponseBody(r) + monobankTransaction, err = readRequestBody(r) if err != nil { LogString(err.Error()) w.WriteHeader(http.StatusOK)