All Projects → jsoendermann → Hapttic

jsoendermann / Hapttic

Licence: other
⏩ Hapttic is a simple HTTP server that forwards all requests to a shell script.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Hapttic

Hgw
hgw是由gateway网关服务、manager控制服务构成的一套轻量级网关系统。目前支持http/https协议的服务控制
Stars: ✭ 81 (-36.72%)
Mutual labels:  http-proxy, http-server
Coroute
Node HTTP reverse-proxy server
Stars: ✭ 147 (+14.84%)
Mutual labels:  http-proxy, http-server
Qtnetworkng
QtNetwork Next Generation. A coroutine based network framework for Qt/C++, with more simpler API than boost::asio.
Stars: ✭ 125 (-2.34%)
Mutual labels:  http-proxy, http-server
httoop
HTTOOP - a fully object oriented HTTP protocol library written in python
Stars: ✭ 15 (-88.28%)
Mutual labels:  http-proxy, http-server
Fht2p
A cross-platform HTTP static file server developed using Rust.
Stars: ✭ 28 (-78.12%)
Mutual labels:  http-proxy, http-server
Proxy admin free
Proxy是高性能全功能的http代理、https代理、socks5代理、内网穿透、内网穿透p2p、内网穿透代理、内网穿透反向代理、内网穿透服务器、Websocket代理、TCP代理、UDP代理、DNS代理、DNS加密代理,代理API认证,全能跨平台代理服务器。
Stars: ✭ 487 (+280.47%)
Mutual labels:  http-proxy, http-server
foxy
Session-based Beast/Asio wrapper requiring C++14
Stars: ✭ 61 (-52.34%)
Mutual labels:  http-proxy, http-server
Foxy
Session-based Beast/Asio wrapper requiring C++14
Stars: ✭ 57 (-55.47%)
Mutual labels:  http-proxy, http-server
Proxy.py
⚡⚡⚡Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on Network monitoring, controls & Application development, testing, debugging
Stars: ✭ 1,291 (+908.59%)
Mutual labels:  http-proxy, http-server
Microproxy
Lightweight non-caching HTTP(S) proxy server
Stars: ✭ 112 (-12.5%)
Mutual labels:  http-proxy
Stdinho
🔌 Turn any STDIN/STDOUT into HTTP server
Stars: ✭ 120 (-6.25%)
Mutual labels:  http-server
Httpproxy
Go HTTP proxy server library
Stars: ✭ 110 (-14.06%)
Mutual labels:  http-proxy
Gus Proxy
"打一枪换一个地方" 一个HTTP代理
Stars: ✭ 113 (-11.72%)
Mutual labels:  http-proxy
Raxx kit
Get started with Raxx + Elixir
Stars: ✭ 120 (-6.25%)
Mutual labels:  http-server
Qhttpengine
HTTP server for Qt applications
Stars: ✭ 112 (-12.5%)
Mutual labels:  http-server
Reverse proxy plug
🔛 an Elixir reverse proxy Plug with HTTP/2, chunked transfer and path proxying support
Stars: ✭ 112 (-12.5%)
Mutual labels:  http-server
Zetaipc
A tiny .NET library to do inter-process communication (IPC) between different processes on the same machine.
Stars: ✭ 111 (-13.28%)
Mutual labels:  http-server
Java Express
🧪 HTTP Framework based on expressjs, no dependencies, simple usage. Can be used to quickly spin up an API or serve local files.
Stars: ✭ 125 (-2.34%)
Mutual labels:  http-server
Flynet
A powerful TCP/UDP tool, which support socks5 proxy by tcp and udp, http proxy and NAT traversal. This tool can help you bypass gfw easily
Stars: ✭ 124 (-3.12%)
Mutual labels:  http-proxy
Goproxy
🔥 Proxy is a high performance HTTP(S) proxies, SOCKS5 proxies,WEBSOCKET, TCP, UDP proxy server implemented by golang. Now, it supports chain-style proxies,nat forwarding in different lan,TCP/UDP port forwarding, SSH forwarding.Proxy是golang实现的高性能http,https,websocket,tcp,socks5代理服务器,支持内网穿透,链式代理,通讯加密,智能HTTP,SOCKS5代理,黑白名单,限速,限流量,限连接数,跨平台,KCP支持,认证API。
Stars: ✭ 11,334 (+8754.69%)
Mutual labels:  http-proxy

hapttic

What is this good for?

  • You want to run some code in response to a webhook, like a github push.
  • You have some code on your Raspberry Pi that you want to run from work (great in combination with ngrok).
  • That's pretty much it.

How does it work?

Hapttic 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.

Isn't this just a reinvention of CGI?

The 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.

Show me an example

First, create a request handler at ~/hapttic_request_handler.sh:

echo $1

Then run the following command to spin up the docker container that runs hapttic:

docker run --rm -p 8080:8080 -v ~/hapttic_request_handler.sh:/hapttic_request_handler.sh --name hapttic jsoendermann/hapttic -file "/hapttic_request_handler.sh"

Finally, run open http://localhost:8080 to see the output of your script.

Show me a more realistic example

REQUEST=$1
SECRET_TOKEN=$(jq -r '.Header."X-My-Secret"[0]' <(echo $REQUEST))

if [[ "$SECRET_TOKEN" != "SECRET" ]]; then
  echo "Incorrect secret token"
  exit -1
fi

curl https://www.example.com/api/call/in/response/to/webhook

This request handling script can be run with curl -H "X-My-Secret: SECRET" http://localhost:8080

The jsoendermann/hapttic Dockerfile includes jq and curl, if you need any other command in your request handling script, you should create your own image.

The Request JSON object

The JSON object your request handling script gets called with is a subset of Go's http.Request. It's defined in hapttic.go as marshallableRequest. For documentation on http.Request, see the official net/http page.

SSL Support

You can add encryption by putting an nginx proxy in front of it with a docker-compose file like so:

version: '3'

volumes:
  vhost:
  html:

services:
  nginx-proxy:
    restart: always
    image: jwilder/nginx-proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - /var/certs:/etc/nginx/certs:ro
      - vhost:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"

  letsencrypt-nginx-proxy-companion:
    restart: always
    image: jrcs/letsencrypt-nginx-proxy-companion
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /var/certs:/etc/nginx/certs:rw
      - vhost:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html

  hapttic:
    restart: always
    image: jsoendermann/hapttic
    environment:
      - VIRTUAL_HOST=hapttic.your.domain.com                                # Replace this
      - LETSENCRYPT_HOST=hapttic.your.domain.com                            # Replace this
      - [email protected]                                # Replace this
    volumes:
      - /my-request-handler.sh:/hapttic_request_handler.sh                  # Replace this
    command: ["-file", "/hapttic_request_handler.sh"]
    depends_on:
      - nginx-proxy
      - letsencrypt-nginx-proxy-companion
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].