mirror of
https://github.com/adnanh/webhook.git
synced 2025-05-30 01:02:29 +00:00
Merge pull request #486 from moorereason/iss439-raw-body
Add option to send raw request body to command
This commit is contained in:
commit
2e4aea4cbc
4 changed files with 50 additions and 9 deletions
|
@ -31,15 +31,16 @@ import (
|
|||
|
||||
// Constants used to specify the parameter source
|
||||
const (
|
||||
SourceHeader string = "header"
|
||||
SourceQuery string = "url"
|
||||
SourceQueryAlias string = "query"
|
||||
SourcePayload string = "payload"
|
||||
SourceRequest string = "request"
|
||||
SourceString string = "string"
|
||||
SourceEntirePayload string = "entire-payload"
|
||||
SourceEntireQuery string = "entire-query"
|
||||
SourceEntireHeaders string = "entire-headers"
|
||||
SourceHeader string = "header"
|
||||
SourceQuery string = "url"
|
||||
SourceQueryAlias string = "query"
|
||||
SourcePayload string = "payload"
|
||||
SourceRawRequestBody string = "raw-request-body"
|
||||
SourceRequest string = "request"
|
||||
SourceString string = "string"
|
||||
SourceEntirePayload string = "entire-payload"
|
||||
SourceEntireQuery string = "entire-query"
|
||||
SourceEntireHeaders string = "entire-headers"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -459,6 +460,9 @@ func (ha *Argument) Get(r *Request) (string, error) {
|
|||
case SourceString:
|
||||
return ha.Name, nil
|
||||
|
||||
case SourceRawRequestBody:
|
||||
return string(r.Body), nil
|
||||
|
||||
case SourceRequest:
|
||||
if r == nil || r.RawRequest == nil {
|
||||
return "", errors.New("request is nil")
|
||||
|
|
|
@ -311,6 +311,17 @@
|
|||
],
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "txt-raw",
|
||||
"execute-command": "{{ .Hookecho }}",
|
||||
"command-working-directory": "/",
|
||||
"include-command-output-in-response": true,
|
||||
"pass-arguments-to-command": [
|
||||
{
|
||||
"source": "raw-request-body"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sendgrid",
|
||||
"execute-command": "{{ .Hookecho }}",
|
||||
|
|
|
@ -172,6 +172,13 @@
|
|||
name: "app.messages.message.#text"
|
||||
value: "Hello!!"
|
||||
|
||||
- id: txt-raw
|
||||
execute-command: '{{ .Hookecho }}'
|
||||
command-working-directory: /
|
||||
include-command-output-in-response: true
|
||||
pass-arguments-to-command:
|
||||
- source: raw-request-body
|
||||
|
||||
- id: sendgrid
|
||||
execute-command: '{{ .Hookecho }}'
|
||||
command-working-directory: /
|
||||
|
|
|
@ -882,6 +882,25 @@ env: HOOK_head_commit.timestamp=2013-03-12T08:14:29-07:00
|
|||
`success`,
|
||||
``,
|
||||
},
|
||||
{
|
||||
"txt-raw",
|
||||
"txt-raw",
|
||||
nil,
|
||||
"POST",
|
||||
map[string]string{"Content-Type": "text/plain"},
|
||||
"text/plain",
|
||||
`# FOO
|
||||
|
||||
blah
|
||||
blah`,
|
||||
false,
|
||||
http.StatusOK,
|
||||
`# FOO
|
||||
|
||||
blah
|
||||
blah`,
|
||||
``,
|
||||
},
|
||||
{
|
||||
"payload-json-array",
|
||||
"sendgrid",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue