Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement path-based claims, as well as vhost-based claims
- Loading branch information
Showing
8 changed files
with
190 additions
and
142 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
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,27 @@ | ||
-module(reqparser_path). | ||
|
||
-export([analyse/2, ext_url/3]). | ||
|
||
analyse(Req, Config) -> | ||
case reversehttp:match_access_point(Req, Config) of | ||
V = {access_point, _, _, _} -> | ||
V; | ||
{normal, Path} -> | ||
case extract_label(Path) of | ||
{ok, HostLabel} -> | ||
{single_request, ext_url(Req, Config, HostLabel)}; | ||
{error, no_slash} -> | ||
{normal, Path} | ||
end | ||
end. | ||
|
||
extract_label(Path) -> | ||
case string:chr(Path, $/) of | ||
0 -> | ||
{error, no_slash}; | ||
N -> | ||
{ok, string:left(Path, N - 1)} | ||
end. | ||
|
||
ext_url(Req, _Config, HostLabel) -> | ||
"http://" ++ string:to_lower(Req:get_header_value(host)) ++ "/" ++ HostLabel ++ "/". |
Oops, something went wrong.