{"id":17231820,"url":"https://github.com/pierreprinetti/gateway","last_synced_at":"2025-03-26T00:25:15.897Z","repository":{"id":57589239,"uuid":"124680207","full_name":"pierreprinetti/gateway","owner":"pierreprinetti","description":"A simplistic reverse proxy for HTTP and NSQ upstreams","archived":false,"fork":false,"pushed_at":"2018-03-11T16:32:42.000Z","size":2667,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T16:57:09.625Z","etag":null,"topics":["configuration","environment","http","nsq","reverse-proxy"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/pierreprinetti/gateway/","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/pierreprinetti.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}},"created_at":"2018-03-10T17:31:02.000Z","updated_at":"2019-08-01T17:31:53.000Z","dependencies_parsed_at":"2022-09-26T22:20:35.079Z","dependency_job_id":null,"html_url":"https://github.com/pierreprinetti/gateway","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreprinetti%2Fgateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreprinetti%2Fgateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreprinetti%2Fgateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreprinetti%2Fgateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pierreprinetti","download_url":"https://codeload.github.com/pierreprinetti/gateway/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245564124,"owners_count":20636057,"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":["configuration","environment","http","nsq","reverse-proxy"],"created_at":"2024-10-15T04:59:03.536Z","updated_at":"2025-03-26T00:25:15.848Z","avatar_url":"https://github.com/pierreprinetti.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gateway\n[![Build Status](https://travis-ci.org/pierreprinetti/gateway.svg?branch=master)](https://travis-ci.org/pierreprinetti/gateway)\n[![Coverage Status](https://coveralls.io/repos/github/pierreprinetti/gateway/badge.svg?branch=master)](https://coveralls.io/github/pierreprinetti/gateway?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/pierreprinetti/gateway)](https://goreportcard.com/report/github.com/pierreprinetti/gateway)\n\nThis is a simplistic reverse proxy for HTTP and NSQ upstreams.\n\nIt gathers its configuration from the environment to map a resouce with an upstream. Every HTTP verb has to be configured independently.\n\n## Configuration\n\nThe initialisation function will parse all the environment variable keys starting with the prefix `PROXY_`. The key has to contain the HTTP method and the resource name to be bound to the upstream.\n\nExample:\n```shell\nexport PROXY_GET_users='http://user_service'\nexport PROXY_PATCH_users='nsq://nsqd:4150/users'\n```\n\nWith these environment variables:\n\n* every `GET` call to `/users/*` will be routed to `http://user_service`;\n* every `PATCH` call to `/users/*` will be forwarded as a NSQ message to the NSQ broker on host `nsqd:4150` with the topic `users`.\n\n### In a docker-compose.yml\n\nThis gateway is available in the public Docker registry as `pierreprinetti/gateway`.\n\n```yaml\nversion: '3'\nservices:\n  gateway:\n    image: pierreprinetti:gateway\n    environment:\n      PROXY_GET_users: 'http://user_service'\n      PROXY_PATCH_users: 'nsq://nsqd:4150/users'\n    depends_on:\n      - user_service\n      - nsqd\n    ports:\n      - '80:80'\n```\n\n### NSQ forwarding\n\nThe nsq connection string must have `nsq` as the protocol and be in the form:\n\n```\nnsq://host:port/topic\n```\n\nThe incoming HTTP requests are packed in a JSON message containing the url and the body of the request.\n\nExample:\n```Javascript\n{\n  \"url\": \"/users/abc\",\n  \"body\": \"{\\\"first_name\\\":\\\"John\\\",\\\"age\\\":42}\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierreprinetti%2Fgateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpierreprinetti%2Fgateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierreprinetti%2Fgateway/lists"}