push endpoint
Some checks failed
Build and Publish / BuildAndDeploy (push) Successful in 3m16s
Build and Publish / BuildAndDeployAmd64 (push) Has been cancelled

This commit is contained in:
matst80
2025-04-18 16:38:24 +02:00
parent 7d27257a71
commit 9f585eec2e
3 changed files with 165 additions and 10 deletions

17
main.go
View File

@@ -1,6 +1,7 @@
package main
import (
"encoding/json"
"fmt"
"log"
"net"
@@ -181,7 +182,21 @@ func main() {
w.Write([]byte("ok"))
})
mux.HandleFunc("/push", func(w http.ResponseWriter, r *http.Request) {
log.Print(r.Body)
log.Printf("KLARNA PUSH: search %v, body %s", r.URL.Query(), r.Body)
if r.Method != http.MethodPost {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
var data OrderValidationBody
err := json.NewDecoder(r.Body).Decode(&data)
if err != nil {
log.Printf("Error decoding body: %v\n", err)
w.WriteHeader(http.StatusBadRequest)
return
}
cartId := data.MerchantReference1
log.Printf("Received push for cart %s, status: %s", cartId, data.Status)
w.WriteHeader(http.StatusOK)
})
mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)