Rendering Directories with Req module.

18 views
Skip to first unread message

lee

unread,
Aug 9, 2016, 6:36:06 PM8/9/16
to MochiWeb
I noticed that mochiweb attempts to find/render index.html whenever a folder is requested using Req:serve_file. Specifically:

<code>
serve_file(Path, DocRoot, ExtraHeaders) ->
     case mochiweb_util:safe_relative_path(Path) of
         undefined ->
             not_found(ExtraHeaders);
         RelPath ->
             FullPath = filename:join([DocRoot, RelPath]),
             File = case filelib:is_dir(FullPath) of
                 true ->
                     filename:join([FullPath, "index.html"]);
                 false ->
                     FullPath
                 end,
</code>

For my project, I would like to render a directory much like an apache web server, is this available in mochiweb by default?

Any thoughts would be highly appreciated, thanks!

Bob Ippolito

unread,
Aug 9, 2016, 6:39:28 PM8/9/16
to moch...@googlegroups.com
This is not behavior that ships with mochiweb, it's designed to be more like a library for building a web service rather than a full featured web server itself. You can of course implement this yourself without too much code, or choose something else that ships with this behavior (Yaws probably does, for example).

--
You received this message because you are subscribed to the Google Groups "MochiWeb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mochiweb+unsubscribe@googlegroups.com.
To post to this group, send email to moch...@googlegroups.com.
Visit this group at https://groups.google.com/group/mochiweb.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages