diff options
author | Robby Zambito <contact@robbyzambito.me> | 2025-02-01 20:45:30 -0500 |
---|---|---|
committer | Robby Zambito <contact@robbyzambito.me> | 2025-02-09 17:06:19 -0500 |
commit | 32c110edfb97abce50ed1d57e529cb7eda2428dd (patch) | |
tree | a4cc51b42467b5616a81f3cb050106046a657738 | |
parent | 7101dd003be4b85ac57b387998d22cc6eaf4aa51 (diff) |
Use 404 when there are no NATS handlers
-rw-r--r-- | main.go | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -120,8 +120,14 @@ func main() { // Send the NATS request and wait synchronously for a reply (timeout: 30 seconds) reply, err := nc.RequestMsg(&msg, 30*time.Second) if err != nil { - http.Error(w, "Error processing request", http.StatusInternalServerError) log.Println("NATS request error:", err) + + // Handle specific NATS error cases + if err == nats.ErrNoResponders || strings.Contains(err.Error(), "no responders") { + http.Error(w, "No service available to handle request", http.StatusNotFound) + } else { + http.Error(w, "Error processing request", http.StatusInternalServerError) + } return } |