-module(rinamo_app).

-behaviour(application).

%% Application callbacks
-export([start/2, stop/1]).

%% ===================================================================
%% Application callbacks
%% ===================================================================

start(_StartType, _StartArgs) ->
  case rinamo_config:is_enabled() of
      true -> add_routes();
      _ -> ok
  end,

  rinamo_sup:start_link().

stop(_State) ->
  [webmachine_router:remove_route(R) || R <- routes()].

%% ===================================================================
%% Internal functions
%% ===================================================================

add_routes() ->
  [webmachine_router:add_route(R) || R <- routes()].

props() ->
  [].

routes() ->
  [
    {[rinamo_config:endpoint_prefix()], rinamo_wm_endpoint, props()},
    {[rinamo_config:endpoint_prefix(), "ping"], rinamo_wm_ping, props()}
  ].

-module(rinamo_app).

-behaviour(application).

%% Application callbacks
-export([start/2, stop/1]).

%% ===================================================================
%% Application callbacks
%% ===================================================================

start(_StartType, _StartArgs) ->
    case rinamo_config:is_enabled() of
        true -> 
            start_cowboy(),
            rinamo_sup:start_link();
        _ -> 
            ok
    end.

stop(_State) ->
    ok.

%% ===================================================================
%% Internal functions
%% ===================================================================

add_routes() ->
  [webmachine_router:add_route(R) || R <- routes()].

props() ->
  [].

routes() ->
  [
    {[rinamo_config:endpoint_prefix()], rinamo_wm_endpoint, props()},
    {[rinamo_config:endpoint_prefix(), "ping"], rinamo_wm_ping, props()}
  ].

Set rinamo supervisor link to only be created if we can startup the application. Started the work or removing Webmachine dependency and migrating to cowboy as a standalone HTTP server to act as the rinamo API interface.
Set rinamo supervisor link to only be created if we can startup the application.  Started the work or removing Webmachine dependency and migrating to cowboy as a standalone HTTP server to act as the rinamo API interface.
