Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
[access]: integrate quotes parsing to access(routing) pasing
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewerr committed Jan 17, 2022
1 parent f5c5095 commit b849a79
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion config/routes.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# MeowMeow routing configuration

# From 1.02-prebeta-r13:
# * All strings with space inside MUST be in quotes

Route *
Set-Header X-Powered-By Pusheen the Cat
Set-Header X-Powered-By "Pusheen the Cat"
End

Route /generate_204
Expand Down
5 changes: 3 additions & 2 deletions src/access.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ get_cmd(Cmd) ->
if length(L) == 0 -> pass;
length(L) == 1 -> {string:trim(lists:nth(1, L)), true};
length(L) > 1 -> [K | V] = L,
{K, V}
Args = lists:nth(1, V),
{K, util:parse_arguments(Args)}
end.

parse_line(Dev, {ok, Line}) ->
Expand Down Expand Up @@ -65,7 +66,7 @@ get_rules(Request, Array, Rules) ->
case H of
{Type, Pattern, List} ->
get_rules_checked(Request, {Type, Pattern, List}, Rules, T);
Any->
_->
get_rules(Request, T, Rules++[H])
end.

Expand Down
3 changes: 1 addition & 2 deletions src/rules.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ rule_no_content(_, Response) ->
rule_disallow(_, _) ->
{aborted, 403}.

rule_set_header(Arg, Response) ->
[Header|Value] = string:split(Arg, " "),
rule_set_header([Header, Value], Response) ->
Response#response{headers = update_headers(Response, #{Header => Value})}.

rule_set_code(Arg, Response)->
Expand Down
2 changes: 1 addition & 1 deletion tests/config/routes.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Route *
Set-Header X-Powered-By Pusheen the Cat
Set-Header X-Powered-By "Pusheen the Cat"
End

Route /generate_204
Expand Down

0 comments on commit b849a79

Please sign in to comment.