Created
May 14, 2020 22:25
-
-
Save felipecrs/d17c7c17ce45ae5989b2d23e1d78602f to your computer and use it in GitHub Desktop.
Gerrit Webhook to GitHub Repository Dispatch API Converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local json = require("json") | |
-- request body is in r.RequestBody, use it as any other string: | |
local body, err = json.decode(r.RequestBody) | |
if err then error(err) end | |
local new_body = { | |
event_type = "gerrit-" .. body["type"], | |
client_payload = body | |
} | |
local new_body, err = json.encode(new_body) | |
if err then error(err) end | |
-- set body | |
r:SetRequestBody(new_body) | |
-- set method | |
-- r:SetRequestMethod("string") | |
-- set raw query | |
-- r:SetRequestRawQuery("foo=bar") | |
-- set extra path | |
-- r:SetRequestPath("/extra/path") | |
-- set header | |
-- r:SetRequestHeader("Accept", "application/vnd.github.everest-preview+json") | |
-- r:SetRequestHeader("Accept", "application/vnd.github.everest-preview+json") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment