internal product index
This commit is contained in:
@@ -80,10 +80,10 @@ func (s *PoolServer) AddSkuToCartHandler(w http.ResponseWriter, r *http.Request,
|
||||
// product-fetcher's "product service returned %d for sku %s" shape so
|
||||
// upstream code that pattern-matches that string still works, AND we
|
||||
// publish StatusNotFound so the HTTP response carries the right code
|
||||
// (the handler's error-return path otherwise renders as 500).
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
_, _ = w.Write([]byte(fmt.Sprintf(`{"error":"product service returned %d for sku %s (bus-deleted)","sku":%q}`, 404, sku, sku)))
|
||||
// (the handler's error-return path otherwise renders as 500). http.Error
|
||||
// is the idiomatic stdlib call here — it does the encoding-safe text body
|
||||
// (no fmt.Sprintf/JSON-string-escaping fragility).
|
||||
http.Error(w, fmt.Sprintf("product service returned %d for sku %s (bus-deleted)", 404, sku), http.StatusNotFound)
|
||||
return nil
|
||||
}
|
||||
msg, err := GetItemAddMessage(r.Context(), sku, 1, getCountryFromHost(r.Host), nil)
|
||||
|
||||
Reference in New Issue
Block a user