diff options
author | Robby Zambito <contact@robbyzambito.me> | 2025-02-01 12:36:05 -0500 |
---|---|---|
committer | Robby Zambito <contact@robbyzambito.me> | 2025-02-09 16:21:36 -0500 |
commit | 7101dd003be4b85ac57b387998d22cc6eaf4aa51 (patch) | |
tree | bd579bce3255f875516f77bac9dd8ae2fe5162df /main.go | |
parent | cb61f0817fa4206ad4482b7337e618f80776cc27 (diff) |
Add support for inbox prefix
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -24,6 +24,7 @@ func printHelp() { fmt.Println(" NATS_NKEY - NATS NKEY for authentication (optional)") fmt.Println(" NATS_NKEY_SEED - NATS NKEY seed for authentication (optional)") fmt.Println(" NATS_CREDS_FILE - Path to NATS credentials file (optional)") + fmt.Println(" NATS_INBOX_PREFIX - Subject prefix for NATS messages (default: _INBOX)") fmt.Println(" HTTP_PORT - HTTP port to listen on (default: 8080)") } @@ -46,6 +47,7 @@ func main() { natsNkey := os.Getenv("NATS_NKEY") natsNkeySeed := os.Getenv("NATS_NKEY_SEED") natsCredsFile := os.Getenv("NATS_CREDS_FILE") + natsInboxPrefix := os.Getenv("NATS_INBOX_PREFIX") // Read HTTP port from environment variables httpPort := os.Getenv("HTTP_PORT") @@ -66,6 +68,10 @@ func main() { opts = append(opts, nats.UserCredentials(natsCredsFile)) } + if natsInboxPrefix != "" { + opts = append(opts, nats.CustomInboxPrefix(natsInboxPrefix)) + } + nc, err := nats.Connect(natsURL, opts...) if err != nil { log.Fatal("Error connecting to NATS:", err) |