From 68e8ee65ffb71ed179d365da5d2a699bf8b47ec2 Mon Sep 17 00:00:00 2001 From: jbergner Date: Tue, 29 Apr 2025 15:12:47 +0200 Subject: [PATCH] Patch --- main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.go b/main.go index b7c1efd..7adf0f3 100644 --- a/main.go +++ b/main.go @@ -717,16 +717,22 @@ func (s *server) handleNewAccount(ctx context.Context, w http.ResponseWriter, r } func (s *server) handleNewOrder(ctx context.Context, w http.ResponseWriter, r *http.Request) { + lg := slog.New(slog.NewJSONHandler(os.Stdout, nil)) + slog.SetDefault(lg) + pay, ok := s.verifyJWS(ctx, w, r) if !ok { + lg.Error("handleNewOrder", "pay", "") return } var req acme.Order if err := json.Unmarshal(pay.Data, &req); err != nil { + lg.Error("handleNewOrder", "json.Unmarshal", err.Error()) http.Error(w, "bad order", 400) return } if len(req.Identifiers) == 0 { + lg.Error("handleNewOrder", "req.Identifiers", "") http.Error(w, "missing identifiers", 400) return } @@ -738,6 +744,7 @@ func (s *server) handleNewOrder(ctx context.Context, w http.ResponseWriter, r *h // Persist order minimal info (we ignore authz for brevity) payload, _ := json.Marshal(req) if _, err := s.db.db.ExecContext(ctx, `INSERT INTO orders(id,payload,status,finalize_url) VALUES (?,?,?,?)`, orderID, payload, acme.StatusPending, finURL); err != nil { + lg.Error("handleNewOrder", "ExecContent", err.Error()) http.Error(w, "db", 500) return } @@ -759,6 +766,8 @@ func (s *server) handleNewOrder(ctx context.Context, w http.ResponseWriter, r *h nonce := uuid.New().String() _ = s.db.putNonce(ctx, nonce) + lg.Error("handleNewOrder", "Function", "Final") + w.Header().Set("Location", ordURL) s.jsonResponse(w, 201, resp, nonce) }