Skip to content

antonioaguilar/gnats-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gnats-proxy

License MIT Go Report Card

This proxy server allows clients to arbitrarily specify a NATS.io subject and publish messages directly to NATS.io without using the default NATS.io client libraries.

Install

$ go get -u github.com/antonioaguilar/gnats-proxy

Usage

$ gnats-proxy --help

usage: gnats-proxy [options]

  -C file
    	Server certificate file
  -K file
    	Private key file
  -d debug
    	Enable debug output (default: true)
  -n URL
    	NATS server URL (default: "nats://0.0.0.0:4222")
  -p Port number
    	Port number (default: 8080)

Publishing data to NATS

External clients can issue HTTP post requests to the default route / and publish messages directly to NATS.io, for example:

curl -s -H "Content-Type: application/json" \
-X POST -d '{"__subject":"CUSTOMER","account":"ACC-123456789","orders":"PO-123456789"}' \
http://localhost:8080/

This command will post the JSON data to the default route http://localhost:8080/, the gnats-proxy server will read and parse the JSON data and will publish this data to NATS.io with a subject called CUSTOMER.

Run as Docker container

You can run gnats-proxy in a Docker container as follows:

# pull the image
docker pull aaguilar/gnats-proxy

# run the container
docker run -it --rm -p 8080:8080 aaguilar/gnats-proxy -p 8080 -n nats://localhost:4222

About

A simple NATS.io messaging proxy in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published