Skip to content

Instantly share code, notes, and snippets.

@yowchun93
Last active March 29, 2020 00:31
Show Gist options
  • Save yowchun93/5a86b11bcaf16da8dce9b65b1af69c84 to your computer and use it in GitHub Desktop.
Save yowchun93/5a86b11bcaf16da8dce9b65b1af69c84 to your computer and use it in GitHub Desktop.
Function clauses
defmodule Servy.Handler do
def route(conv) do
if conv.path == '/wildthings' do
%{ conv | resp_body: "Bears, Lions, Tigers"}
else
%{ conv | r esp_body: "Bears"}
end
end
end
# Refactor
def route(conv = %{path: "/wildthings"}) do
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment