mirror of
https://git.robbyzambito.me/http-nats-proxy
synced 2025-12-20 08:14:51 +00:00
Use 404 when there are no NATS handlers
This commit is contained in:
8
main.go
8
main.go
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user