From c807880f7ac73f813b2660ea81a00f7712a4e793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 29 Aug 2016 12:39:49 +0200 Subject: Add old mailing list archives --- .../archives/extend/2015-January/000507.html | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 _build/static/archives/extend/2015-January/000507.html (limited to '_build/static/archives/extend/2015-January/000507.html') diff --git a/_build/static/archives/extend/2015-January/000507.html b/_build/static/archives/extend/2015-January/000507.html new file mode 100644 index 00000000..a16a39c2 --- /dev/null +++ b/_build/static/archives/extend/2015-January/000507.html @@ -0,0 +1,100 @@ + + + + [99s-extend] Rewriting URLs + + + + + + + + + + +

[99s-extend] Rewriting URLs

+ Paul Dickson + pdtwonotes at gmail.com +
+ Tue Jan 27 14:44:14 CET 2015 +

+
+ +
Ok, here is all the code in bz_libmap.erl
+
+execute(Req, Env) ->
+    Path = cowboy_req:path(Req),
+    Parts = filename:split(Path),
+
+    case cowboy_req:method(Req) of
+      <<"GET">> ->
+         % Check for "/music/" requests
+         rewrite( Parts, Req, Env );
+      _Other ->
+         {ok, Req, Env}
+    end.
+
+rewrite( [<<"/">>, <<"music">>, LibName | UrlParts], Req, Env ) ->
+    % We want URLs of the form "/music/LIBNAME/everythingelse"
+    % Get library definition.  If we do not know that name, then they
+    % are asking for something that does not exist.
+    case bz_db:get_library( LibName ) of
+      [] ->
+         io:format("No such library '~s'~n", [LibName] ),
+         {stop, cowboy_req:reply(404, Req)};
+
+      L when is_record(L,library) ->
+          % Replace the library name with the library base.
+          % This will be the head of an absolute file path.
+          LibBase = L#library.base,
+          NewPath = filename:join([LibBase | UrlParts]),
+          NewInfo = filename:split(NewPath),
+          Req2 = cowboy_req:set( [
+            {path_info,[NewPath]},
+            {path, [NewPath]}], Req),
+          {ok, Req2, Env}
+    end;
+rewrite( _AnythingElse, Req, Env ) ->
+    {ok, Req, Env}.
+
+
+
+
+ + + +
+

+ +
+More information about the Extend +mailing list
+ -- cgit v1.2.3