{"id":18403728,"url":"https://github.com/russellluo/hats","last_synced_at":"2025-04-07T07:32:46.668Z","repository":{"id":244622672,"uuid":"815423302","full_name":"RussellLuo/hats","owner":"RussellLuo","description":"Communicating with NATS using the HTTP protocol.","archived":false,"fork":false,"pushed_at":"2024-06-22T03:31:38.000Z","size":96,"stargazers_count":17,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-22T14:41:30.663Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/RussellLuo/hats","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RussellLuo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-15T05:53:23.000Z","updated_at":"2025-02-11T21:31:41.000Z","dependencies_parsed_at":"2024-06-22T15:39:24.016Z","dependency_job_id":null,"html_url":"https://github.com/RussellLuo/hats","commit_stats":null,"previous_names":["russellluo/hats"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RussellLuo%2Fhats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RussellLuo%2Fhats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RussellLuo%2Fhats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RussellLuo%2Fhats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RussellLuo","download_url":"https://codeload.github.com/RussellLuo/hats/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247612515,"owners_count":20966768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T02:48:01.974Z","updated_at":"2025-04-07T07:32:45.470Z","avatar_url":"https://github.com/RussellLuo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hats\n\n[![Go Reference](https://pkg.go.dev/badge/RussellLuo/hats/vulndb.svg)][1]\n\nCommunicating with NATS using the HTTP protocol.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"hats.drawio.png\" height=\"200\"\u003e\n\u003c/p\u003e\n\n\n## Installation\n\n```bash\ngo install github.com/RussellLuo/hats@latest\n```\n\n\u003cdetails open\u003e\n  \u003csummary\u003e Usage \u003c/summary\u003e\n\n```bash\n$ hats -h\nUsage of hats:\n  -config string\n    \tYAML/JSON file to read configuration from\n  -nats string\n    \tThe URL of the NATS server (default \"nats://127.0.0.1:4222\")\n  -pub_addr string\n    \tThe listen address of the publishing server (default \":8080\")\n  -pub_key string\n    \tThe auth key for the endpoints of the publishing server\n  -sub_stream -sub_stream\n    \tThe JSON config of a single stream (Set multiple -sub_stream for multiple streams)\n  -sub_webhook_key string\n    \tThe auth key of the default webhook\n  -sub_webhook_url string\n    \tThe URL of the default webhook (default \"http://127.0.0.1:8080/webhook\")\n```\n\n\u003c/details\u003e\n\n\n## Prerequisites\n\nStart a JetStream enabled NATS server ([docs][2]):\n\n```bash\ndocker network create nats\ndocker run --name nats --network nats -p 4222:4222 -d nats -js\n```\n\nCreate a stream ([docs][3]):\n\n```bash\nnats stream add ORDERS --subjects='ORDERS.*'\n```\n\n\n## Quick Start\n\n### Using the default webhook\n\nRun the `hats` server:\n\n```bash\nhats -sub_stream='{\"name\":\"ORDERS\",\"consumers\":[{\"durable_name\":\"ORDERS_CONS\"}]}'\n```\n\n\u003e For complex scenarios, you can also use a config file:\n\u003e\n\u003e ```bash\n\u003e $ cat hats.yaml\n\u003e sub:\n\u003e   streams:\n\u003e   - name: ORDERS\n\u003e     consumers:\n\u003e     - durable_name: ORDERS_CONS\n\u003e\n\u003e $ hats -config=hats.yaml\n\u003e ```\n\nPublish a message:\n\n```bash\ncurl -XPOST 'http://127.0.0.1:8080/pub?subject=ORDERS.new' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"order_id\": \"123\"}'\n```\n\nThe published message will be consumed by the default webhook handler, see logs of the `hats` server.\n\n### Using your own webhook\n\nRun the `hats` server:\n\n```bash\nhats \\\n  -sub_stream='{\"name\":\"ORDERS\",\"consumers\":[{\"durable_name\":\"ORDERS_CONS\"}]}' \\\n  -sub_webhook_url='http://127.0.0.1:8081/your-own-webhook' \\\n  -sub_webhook_key='your-own-key'\n```\n\nPublish a message:\n\n```bash\ncurl -XPOST 'http://127.0.0.1:8080/pub?subject=ORDERS.new' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"order_id\": \"123\"}'\n```\n\nThe published message will be consumed by your own webhook handler, turn to your webhook server to see the results.\n\n\n## Documentation\n\nCheckout the [Godoc][1].\n\n\n## License\n\n[MIT](LICENSE)\n\n\n[1]: https://pkg.go.dev/github.com/RussellLuo/hats\n[2]: https://docs.nats.io/running-a-nats-service/nats_docker/jetstream_docker\n[3]: https://docs.nats.io/nats-concepts/jetstream/streams\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frussellluo%2Fhats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frussellluo%2Fhats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frussellluo%2Fhats/lists"}