{"id":13446776,"url":"https://github.com/jsoendermann/hapttic","last_synced_at":"2025-03-21T16:32:49.473Z","repository":{"id":41203230,"uuid":"94500343","full_name":"jsoendermann/hapttic","owner":"jsoendermann","description":":fast_forward: Hapttic is a simple HTTP server that forwards all requests to a shell script.","archived":false,"fork":false,"pushed_at":"2019-02-27T01:16:50.000Z","size":15,"stargazers_count":189,"open_issues_count":1,"forks_count":18,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-28T11:43:29.710Z","etag":null,"topics":["golang","http-proxy","http-server"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsoendermann.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":"2017-06-16T03:13:22.000Z","updated_at":"2024-09-19T13:18:58.000Z","dependencies_parsed_at":"2022-09-13T09:53:02.602Z","dependency_job_id":null,"html_url":"https://github.com/jsoendermann/hapttic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsoendermann%2Fhapttic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsoendermann%2Fhapttic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsoendermann%2Fhapttic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsoendermann%2Fhapttic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsoendermann","download_url":"https://codeload.github.com/jsoendermann/hapttic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244829612,"owners_count":20517342,"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":["golang","http-proxy","http-server"],"created_at":"2024-07-31T05:00:59.601Z","updated_at":"2025-03-21T16:32:49.177Z","avatar_url":"https://github.com/jsoendermann.png","language":"Go","funding_links":[],"categories":["Go","Software","Software Development"],"sub_categories":["Software Development - API Management","API Management"],"readme":"# hapttic\n\n## What is this good for?\n\n- You want to run some code in response to a webhook, like a github push.\n- You have some code on your Raspberry Pi that you want to run from work (great in combination with [ngrok](https://ngrok.com/)).\n- That's pretty much it.\n\n## How does it work?\n\nHapttic listens for incoming HTTP connections. When it receives a connection, it dumps all relevant data (headers, path, parameters, the body and other stuff) into a JSON object and calls a bash script with this object as its parameters.\n\n## Isn't this just a reinvention of CGI?\n\nThe basic idea is pretty similar. The main advantage of hapttic is ease of setup with a simple Docker image that lets you quickly connect a shell script to a http endpoint.\n\n## Show me an example\n\nFirst, create a request handler at `~/hapttic_request_handler.sh`:\n\n```bash\necho $1\n```\n\nThen run the following command to spin up the docker container that runs hapttic:\n\n`docker run --rm -p 8080:8080 -v ~/hapttic_request_handler.sh:/hapttic_request_handler.sh --name hapttic jsoendermann/hapttic -file \"/hapttic_request_handler.sh\"`\n\nFinally, run `open http://localhost:8080` to see the output of your script.\n\n## Show me a more realistic example\n\n```bash\nREQUEST=$1\nSECRET_TOKEN=$(jq -r '.Header.\"X-My-Secret\"[0]' \u003c(echo $REQUEST))\n\nif [[ \"$SECRET_TOKEN\" != \"SECRET\" ]]; then\n  echo \"Incorrect secret token\"\n  exit -1\nfi\n\ncurl https://www.example.com/api/call/in/response/to/webhook\n```\n\nThis request handling script can be run with `curl -H \"X-My-Secret: SECRET\" http://localhost:8080`\n\nThe [`jsoendermann/hapttic`](https://hub.docker.com/r/jsoendermann/hapttic/) Dockerfile includes `jq` and `curl`, if you need any other command in your request handling script, you should create your own image.\n\n## The Request JSON object\n\nThe JSON object your request handling script gets called with is a subset of Go's `http.Request`. It's defined in [hapttic.go](https://github.com/jsoendermann/hapttic/blob/master/hapttic.go) as `marshallableRequest`. For documentation on http.Request, see [the official net/http page](https://golang.org/pkg/net/http/#Request).\n\n## SSL Support\n\nYou can add encryption by putting an nginx proxy in front of it with a docker-compose file like so:\n\n```yaml\nversion: '3'\n\nvolumes:\n  vhost:\n  html:\n\nservices:\n  nginx-proxy:\n    restart: always\n    image: jwilder/nginx-proxy\n    ports:\n      - 80:80\n      - 443:443\n    volumes:\n      - /var/run/docker.sock:/tmp/docker.sock:ro\n      - /var/certs:/etc/nginx/certs:ro\n      - vhost:/etc/nginx/vhost.d\n      - html:/usr/share/nginx/html\n    labels:\n      - \"com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true\"\n\n  letsencrypt-nginx-proxy-companion:\n    restart: always\n    image: jrcs/letsencrypt-nginx-proxy-companion\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock:ro\n      - /var/certs:/etc/nginx/certs:rw\n      - vhost:/etc/nginx/vhost.d\n      - html:/usr/share/nginx/html\n\n  hapttic:\n    restart: always\n    image: jsoendermann/hapttic\n    environment:\n      - VIRTUAL_HOST=hapttic.your.domain.com                                # Replace this\n      - LETSENCRYPT_HOST=hapttic.your.domain.com                            # Replace this\n      - LETSENCRYPT_EMAIL=your@email.address                                # Replace this\n    volumes:\n      - /my-request-handler.sh:/hapttic_request_handler.sh                  # Replace this\n    command: [\"-file\", \"/hapttic_request_handler.sh\"]\n    depends_on:\n      - nginx-proxy\n      - letsencrypt-nginx-proxy-companion\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsoendermann%2Fhapttic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsoendermann%2Fhapttic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsoendermann%2Fhapttic/lists"}