Permalink
Browse files

web resource

  • Loading branch information...
1 parent 1f9a4b5 commit 88f980817424e48381ed5f283041a36ec38430ab @ulfa ulfa committed Feb 16, 2012
Showing with 21 additions and 5 deletions.
  1. +1 −0 priv/dispatch.conf
  2. +8 −4 src/saw_content_resource.erl
  3. +12 −1 src/saw_sup.erl
View
@@ -0,0 +1 @@
+{["content", '*'], saw_content_resource, []}.
@@ -27,7 +27,7 @@
%% --------------------------------------------------------------------
%% External exports
%% --------------------------------------------------------------------
--export([init/1, allowed_methods/2, resource_exists/2]).
+-export([init/1, allowed_methods/2, resource_exists/2, post_is_create/2, process_post/2]).
-include_lib("../deps/webmachine/include/webmachine.hrl").
%% --------------------------------------------------------------------
%% record definitions
@@ -43,9 +43,13 @@ init(_Config) ->
allowed_methods(ReqData, Context) ->
{['POST'], ReqData, Context}.
-to_html(ReqData, Context) ->
- {ok, Content} = about_dtl:render([{version, wurfler:getVersion()}]),
- {Content, ReqData, Context}.
+post_is_create(ReqData, Context) ->
+ {false, ReqData, Context}.
+
+process_post(ReqData, Context) ->
+
+ saw_sliding_w:set_content("Content"),
+ {true, ReqData, Context}.
resource_exists(ReqData, Context) ->
{true, ReqData, Context}.
View
@@ -26,6 +26,8 @@
-define(SWIN, {saw_sliding_w, {saw_sliding_w, start_link, []}, transient, 10000, worker, []}).
-define(SWINTAKT, {saw_sliding_w_takt, {saw_sliding_w_takt, start_link, []}, transient, 10000, worker, []}).
-define(SINPUT, {saw_input, {saw_input, start_link, []}, transient, 10000, worker, []}).
+-define(WEBMACHINE(WebConfig), {webmachine_mochiweb, {webmachine_mochiweb, start, [WebConfig]}, permanent, 5000, worker, dynamic}).
+
%% --------------------------------------------------------------------
%% External exports
%% --------------------------------------------------------------------
@@ -41,6 +43,15 @@ start_link() ->
%% Supervisor callbacks
%% ===================================================================
init([]) ->
+ Ip = case os:getenv("WEBMACHINE_IP") of false -> "0.0.0.0"; Any -> Any end,
+ {ok, Dispatch} = file:consult("./priv/dispatch.conf"),
+ io:format("... ; ~p~n", [Dispatch]),
+ WebConfig = [
+ {ip, Ip},
+ {backlog, 1000},
+ {port, 8002 },
+ {log_dir, "log/weblog"},
+ {dispatch, Dispatch}],
MaxRestart = 1,
MaxTime = 10000,
- {ok, {{one_for_one, MaxRestart, MaxTime}, [?STAKT, ?SPOS, ?SWIN, ?SWINTAKT, ?SINPUT]}}.
+ {ok, {{one_for_one, MaxRestart, MaxTime}, [?STAKT, ?SPOS, ?SWIN, ?SWINTAKT, ?SINPUT, ?WEBMACHINE(WebConfig)]}}.

0 comments on commit 88f9808

Please sign in to comment.