Remove unused function, make forward slash a macro

This commit is contained in:
Maciej Szlosarczyk 2019-07-04 09:15:15 +03:00
parent cde2a7ed55
commit 5c7942f08e
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
2 changed files with 7 additions and 15 deletions

View file

@ -1,13 +1,12 @@
-module(epp_router).
-export([route_request/1, is_valid_epp_command/1, request_method/1]).
-export([route_request/1, request_method/1]).
-define(validCommands, ["hello", "login", "logout", "check", "info", "poll",
"create", "delete", "renew", "update", "transfer"]).
%% Save yourself some checking beforehand.
is_valid_epp_command(Command) ->
lists:member(Command, ?validCommands).
%% 47 is the character code
-define(forwardSlash, 47).
%% request method: GET for greeting, POST for everything else.
request_method("hello") ->
@ -52,16 +51,17 @@ url_map(Command) when is_list(Command) ->
%% This allows the person who configures proxy to not care about trailing
%% slashes in HTTP.
%% 47 is the equivalent for "/"
appendable_route(Route) ->
case lists:last(Route) of
47 -> Route;
?forwardSlash -> Route;
_ -> unicode:characters_to_list([Route, "/"])
end.
%% This allows the person who configures proxy to not care about trailing
%% slashes in HTTP.
parametrizable_route(Route) ->
case lists:last(Route) of
47 -> lists:droplast(Route);
?forwardSlash -> lists:droplast(Route);
_ -> Route
end.

View file

@ -2,14 +2,6 @@
-include_lib("eunit/include/eunit.hrl").
is_valid_epp_command_test() ->
Commands = ["hello", "login", "logout", "check", "info", "poll",
"create", "delete", "renew", "update", "transfer"],
lists:foreach(fun (N) ->
?assert(epp_router:is_valid_epp_command(N))
end,
Commands).
request_method_test() ->
?assertEqual(get, epp_router:request_method("hello")),
?assertEqual(get, epp_router:request_method(<<"hello">>)),