mirror of
https://git.robbyzambito.me/http-nats-proxy
synced 2025-12-20 08:14:51 +00:00
Add support for inbox prefix
This commit is contained in:
6
main.go
6
main.go
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user