Skip to content

Instantly share code, notes, and snippets.

@felipecrs
Created May 14, 2020 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipecrs/d17c7c17ce45ae5989b2d23e1d78602f to your computer and use it in GitHub Desktop.
Save felipecrs/d17c7c17ce45ae5989b2d23e1d78602f to your computer and use it in GitHub Desktop.
Gerrit Webhook to GitHub Repository Dispatch API Converter
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