%%% @doc %%% front end web development lab %%% @end -module(fewd). -vsn("0.1.0"). -behavior(application). -author("Peter Harpending "). -copyright("Peter Harpending "). -license("BSD-2-Clause-FreeBSD"). -export([listen/1, ignore/0]). -export([start/2, stop/1]). -include("$zx_include/zx_logger.hrl"). -spec listen(PortNum) -> Result when PortNum :: inet:port_num(), Result :: ok | {error, {listening, inet:port_num()}}. %% @doc %% Make the server start listening on a port. %% Returns an {error, Reason} tuple if it is already listening. listen(PortNum) -> fd_http:listen(PortNum). -spec ignore() -> ok. %% @doc %% Make the server stop listening if it is, or continue to do nothing if it isn't. ignore() -> fd_http:ignore(). -spec start(normal, term()) -> {ok, pid()}. %% @private %% Called by OTP to kick things off. This is for the use of the "application" part of %% OTP, not to be called by user code. %% See: http://erlang.org/doc/apps/kernel/application.html start(normal, _Args) -> Result = fd_sup:start_link(), ok = listen(8000), Result. -spec stop(term()) -> ok. %% @private %% Similar to start/2 above, this is to be called by the "application" part of OTP, %% not client code. Causes a (hopefully graceful) shutdown of the application. stop(_State) -> ok.