oups payload.cr
parent
f0951210f2
commit
577c7ba5d7
|
@ -0,0 +1,25 @@
|
|||
require "json"
|
||||
|
||||
class Payload
|
||||
include JSON::Serializable
|
||||
|
||||
property kind : String
|
||||
property content : String
|
||||
|
||||
def initialize(req : HTTP::Request)
|
||||
|
||||
agent = req.headers.fetch("User-Agent", "None")
|
||||
if agent == "GiteaServer" && req.headers.has_key?("X-Gitea-Event")
|
||||
@kind = "gitea"
|
||||
elsif agent.starts_with?("GitHub-Hookshot/") && req.headers.has_key?("X-Github-Event")
|
||||
@kind = "github"
|
||||
elsif req.headers.has_key?("X-Gitlab-Event")
|
||||
@kind = "gitlab"
|
||||
else
|
||||
@kind = "undefined"
|
||||
end
|
||||
|
||||
@content = req.body.not_nil!.gets_to_end.to_s
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue