Skip to content

ohto-ai/webhook

Repository files navigation

webhook

License Contributors
Issues Closed Issues
PRs Closed PRs
Stargazers Commit Activity

Cross-platform CI & Release

Top Lang

Alt

Introduction

This repository is a webhook on Linux, Windows and MacOS.

Demo

See here

Release

All | Latest

Build

Ensure you have cmake and build tools installed.

Clone the repository and build it with cmake.

git clone https://github.com/Ohto-Ai/webhook.git
# for chinese user, you can use ghproxy
# git clone https://ghproxy.com/https://github.com/Ohto-Ai/webhook.git
cd webhook

cmake -Bbuild
cmake --build build --config Release --target webhook -j8

Install

You can add this source to source.list, and run this command apt update & apt install ohtoai-webhook.

echo "deb [trusted=yes] https://github.com/Ohto-Ai-Dev/apt-repo/raw/main/ubuntu/ ./" | sudo tee -a /etc/apt/sources.list > /dev/null 
sudo apt update
sudo apt install ohtoai-webhook

Sources:

# GitHub
deb [trusted=yes] https://github.com/Ohto-Ai-Dev/apt-repo/raw/main/ubuntu/ ./

Or you can use python script to download latest version on Linux.

curl -fsSL https://raw.githubusercontent.com/Ohto-Ai/webhook/master/scripts/install.py | python -

Or you can download binary release from GitHub Release.

Usage

See config in ~/.ohtoai/ohtoai-webhook/hook.json. It a simple webhook server.

Sample

hook.json

{
    "hooks": [
        {
            "command": "echo -n \"Hello\"",
            "command_timeout": 8000,
            "method": "GET",
            "name": "hi",
            "path": "/hi",
            "result": {
                "content": [
                    "<h1>{{context.app}} {{context.version}}{{context.commit_hash}}</h1>",
                    "<p>Method: {{request.method}}</p>",
                    "<p>Path: {{request.path}}</p>",
                    "<p>User-Agent: {{request.header.user-agent}}</p>",
                    "<p>Client: {{request.remote_addr}}</p>",
                    "<p>{{command_output}}</p>"
                ],
                "type": "text/html"
            }
        }
    ],
    "listen": {
        "auth": {
            "password": "",
            "path": "/",
            "username": ""
        },
        "host": "localhost",
        "port": 8080,
        "prefix": "/api"
    },
    "log": {
        "console_level": "info",
        "file_level": "info",
        "file_path": "webhook.log",
        "global_level": "info"
    }
}

Star History

Star History Chart