Skip to content

Commit

Permalink
Handle relative paths when Yaws is started in embedded mode
Browse files Browse the repository at this point in the history
Now, following functions will throw an error if the docroot
directory does not exist:

  * yaws_api:embedded_start_conf/1,2,3,4
  * yaws:start_embedded/1,2,3,4
  * yaws:add_server/2
  * yaws:create_sconf/2
  • Loading branch information
Christopher Faulet committed Oct 19, 2012
1 parent 1939b38 commit b3bc43c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/yaws_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,15 @@ make_default_sconf([], Port) ->
make_default_sconf(DocRoot, undefined) ->
make_default_sconf(DocRoot, 8000);
make_default_sconf(DocRoot, Port) ->
set_server(#sconf{port=Port, listen={127,0,0,1}, docroot=DocRoot}).
AbsDocRoot = filename:absname(DocRoot),
case is_dir(AbsDocRoot) of
true ->
set_server(#sconf{port=Port,listen={127,0,0,1},docroot=AbsDocRoot});
false ->
throw({error, ?F("Invalid docroot: directory ~s does not exist",
[AbsDocRoot])})
end.


yaws_dir() ->
%% below, ignore dialyzer warning:
Expand Down

0 comments on commit b3bc43c

Please sign in to comment.