Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Handle relative paths when Yaws is started in embedded mode

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...
commit b3bc43cdf3aaac610e413a929e980ac87af4df00 1 parent 1939b38
@capflam capflam authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/yaws_config.erl
View
10 src/yaws_config.erl
@@ -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:
Please sign in to comment.
Something went wrong with that request. Please try again.