标签:content curl ima .json payload echo width post spl
adnanh webhook是一个很不错的webhook 实现,方便灵活。
adnanh webhook 支持以下功能:
参考git https://github.com/rongfengliang/adnanh-webhook-docker-compose
version: "3"
services:
webhook:
image: almir/webhook
command: ["-verbose", "-hooks=/etc/webhook/hooks.json","-hotreload"]
volumes:
- "./hooks.json:/etc/webhook/hooks.json"
- "./shell/:/shells/"
ports:
- "9000:9000"
[
{
"id": "simple-one",
"execute-command": "/shells/app",
"include-command-output-in-response":true,
"include-command-output-in-response-on-error":true,
"command-working-directory":"/shells",
"pass-arguments-to-command":
[
{
"source": "payload",
"name": "id"
},
{
"source": "url",
"name": "token"
}
],
"trigger-rule":
{
"match":
{
"type": "value",
"value": "42",
"parameter":
{
"source": "url",
"name": "token"
}
}
}
}
]
#!/bin/sh
echo $@ , $1, $2
对于请求参数包含token=42 的才会执行shell 命令,同时将url 参数token 以及payload(post请求)中的id,传递给shell
同时配置了将shell 结果输出到响应,从运行模式来看就类似当前serverless框架的运行原理。
curl -X POST ‘http://localhost:9000/hooks/simple-one?token=44‘ -H ‘cache-control: no-cache‘ -H ‘content-type: application/json‘ -H ‘postman-token: 85f3425b-a0a7-cf80-c49a-87299d905a6c‘ -d ‘{
"id":"dalongdemo"
}‘
Hook rules were not satisfied
curl -X POST ‘http://localhost:9000/hooks/simple-one?token=42‘ -H ‘cache-control: no-cache‘ -H ‘content-type: application/json‘ -H ‘postman-token: 76d20d8d-a72e-9ae4-2570-115f57479116‘ -d ‘{
"id":"dalongdemo"
}‘
dalongdemo 42 , dalongdemo, 42
https://github.com/rongfengliang/adnanh-webhook-docker-compose
https://github.com/adnanh/webhook/blob/master/docs/Referencing-Request-Values.md
adnanh webhook 框架execute-command 以及参数传递处理
标签:content curl ima .json payload echo width post spl
原文地址:https://www.cnblogs.com/rongfengliang/p/9700831.html