Skip to content

Instantly share code, notes, and snippets.

@cored
Created January 30, 2018 13:34
Show Gist options
  • Save cored/ea453cb72c8cf35f337051e45efeaf46 to your computer and use it in GitHub Desktop.
Save cored/ea453cb72c8cf35f337051e45efeaf46 to your computer and use it in GitHub Desktop.
defmodule Servy.Conv do
alias Servy.Conv
defstruct method: "", path: "", resp_body: "", status: nil
def full_status(%Conv{} = conv) do
"#{conv.status} #{status_reason(conv.status)}"
end
defp status_reason(code) do
%{
200 => "OK",
201 => "Created",
401 => "Unauthorized",
403 => "Forbidden",
404 => "Not Found",
500 => "Internal Server Error",
}[code]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment