-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb2934a
commit b7e95df
Showing
3 changed files
with
30 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule Servy.Parser do | ||
def parse(request) do | ||
[method, path, _] = | ||
request | ||
|> String.split("\n") | ||
|> List.first() | ||
|> String.split(" ") | ||
|
||
%{method: method, path: path, resp_body: "", status: nil} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
defmodule Servy.Plugins do | ||
@doc "Logs 404 requests" | ||
def track(%{status: 404, path: path} = conv) do | ||
IO.puts("Warning: #{path} is on the loose!") | ||
conv | ||
end | ||
|
||
def track(conv), do: conv | ||
|
||
def rewrite_path(%{path: "/wildlife"} = conv) do | ||
%{conv | path: "/wildthings"} | ||
end | ||
|
||
def rewrite_path(conv), do: conv | ||
|
||
def log(conv), do: IO.inspect(conv) | ||
end |