Commits

Anonymous committed 7759993

Renamed default bespin_webserver_reource to static_file_resource.

  • Participants
  • Parent commits bb53521
  • Branches static-pages

Comments (0)

Files changed (3)

backend/erlang/bespin_webserver/priv/dispatch.conf

-{['*'], bespin_webserver_resource, [{static_file_dir, "../../frontend/"}]}.
+{['*'], static_file_resource, [{static_file_dir, "../../frontend/"}]}.

backend/erlang/bespin_webserver/src/bespin_webserver_resource.erl

-%% @author author <john.kane84@gmail.com>
-%% @copyright 2009 John Kane.
-%% @doc Example webmachine_resource.
-
--module(bespin_webserver_resource).
--export([init/1]).
--export([allowed_methods/2,
-         provide_content/2,
-         content_types_provided/2]).
-
--include_lib("../deps/webmachine/include/webmachine.hrl").
-
--include_lib("kernel/include/file.hrl").
-
--record(context, {static_file_dir="./../../frontend/"}).
-
-init(ConfigProps) ->
-    {static_file_dir, Dir} = proplists:lookup(static_file_dir, ConfigProps),
-    {ok, #context{static_file_dir=Dir}}.
-  
-allowed_methods(ReqData, Context) ->
-    {['GET'], ReqData, Context}.
-
-file_path(Context, Name) ->
-    RelName = case hd(Name) of
-        "/" -> tl(Name);
-        _ -> Name
-    end,
-    filename:join([Context#context.static_file_dir, RelName]).
-  
-provide_content(ReqData, Context) ->
-  Path = file_path(Context, wrq:disp_path(ReqData)),
-  case filelib:is_regular(Path) of
-    true ->
-      {ok, Value} = file:read_file(Path),
-      {Value, ReqData, Context};
-    false ->
-      {error, ReqData, Context}
-  end.
-
-content_types_provided(ReqData, Context) ->
-    CT = webmachine_util:guess_mime(wrq:disp_path(ReqData)),
-    {[{CT, provide_content}], ReqData, Context}.
-

backend/erlang/bespin_webserver/src/static_file_resource.erl

+%% @author author <john.kane84@gmail.com>
+%% @copyright 2009 John Kane.
+%% @doc Example webmachine_resource.
+
+-module(static_file_resource).
+-export([init/1]).
+-export([allowed_methods/2,
+         provide_content/2,
+         content_types_provided/2]).
+
+-include_lib("../deps/webmachine/include/webmachine.hrl").
+
+-include_lib("kernel/include/file.hrl").
+
+-record(context, {static_file_dir="./../../frontend/"}).
+
+init(ConfigProps) ->
+    {static_file_dir, Dir} = proplists:lookup(static_file_dir, ConfigProps),
+    {ok, #context{static_file_dir=Dir}}.
+  
+allowed_methods(ReqData, Context) ->
+    {['GET'], ReqData, Context}.
+
+file_path(Context, Name) ->
+    RelName = case hd(Name) of
+        "/" -> tl(Name);
+        _ -> Name
+    end,
+    filename:join([Context#context.static_file_dir, RelName]).
+  
+provide_content(ReqData, Context) ->
+  Path = file_path(Context, wrq:disp_path(ReqData)),
+  case filelib:is_regular(Path) of
+    true ->
+      {ok, Value} = file:read_file(Path),
+      {Value, ReqData, Context};
+    false ->
+      {error, ReqData, Context}
+  end.
+
+content_types_provided(ReqData, Context) ->
+    CT = webmachine_util:guess_mime(wrq:disp_path(ReqData)),
+    {[{CT, provide_content}], ReqData, Context}.
+