Skip to content

Commit

Permalink
Allow GitHub-Hookshot to use api/refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
xrchz committed Nov 14, 2017
1 parent 283505d commit 9a273f6
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions server.sml
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,24 @@ fun get_api () =
| _ => SOME (Html Overview))
| (NONE, SOME "GET", _) => SOME (Html Overview)
| (SOME path_info, SOME "POST", auth) =>
let val () = check_auth auth in
case String.tokens (equal #"/") path_info of
["api","log",n] =>
(Option.mapPartial
(fn len =>
Option.compose
((fn id => Post(id,TextIO.inputN(TextIO.stdIn,len))),
id_from_string) n)
(Option.composePartial(Int.fromString,OS.Process.getEnv) "CONTENT_LENGTH"))
| ["api","refresh"] => SOME (Get Refresh) (* GitHub webhook requests this with POST *)
| _ => NONE
let in
case String.tokens (equal #"/") path_info of
["api","log",n] =>
let val () = check_auth auth in
Option.mapPartial
(fn len =>
Option.compose
((fn id => Post(id,TextIO.inputN(TextIO.stdIn,len))),
id_from_string) n)
(Option.composePartial(Int.fromString,OS.Process.getEnv) "CONTENT_LENGTH")
end
| ["api","refresh"] =>
if Option.map
(String.isPrefix "GitHub-Hookshot/")
(OS.Process.getEnv "HTTP_USER_AGENT") = SOME true
then SOME (Get Refresh)
else cgi_die ["Bad request type: wanted GET got POST."]
| _ => NONE
end
| _ => NONE

Expand Down

0 comments on commit 9a273f6

Please sign in to comment.