Skip to content

Instantly share code, notes, and snippets.

@veverkap
Created July 5, 2018 19:50
Show Gist options
  • Save veverkap/df581801eb36f9b3c0a48f69a7f93d5c to your computer and use it in GitHub Desktop.
Save veverkap/df581801eb36f9b3c0a48f69a7f93d5c to your computer and use it in GitHub Desktop.
defmodule SetGithubEvents do
import Plug.Conn
def init(opts), do: opts
def call(conn, _) do
event = List.keyfind(conn.req_headers, signature_header(), 0)
conn
|> handle_event(event)
end
defp handle_event(%{params: params} = conn, {_, "status"}) do
conn
end
defp handle_event(conn, _) do
conn
end
defp signature_header, do: Application.get_env(:forge, :github_event_header, "x-github-event")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment