Because Yaws does not serve static file at a path if there is a handler for the path, to remove the ugly "/web" for Nitrogen on Yaws, I think we can do manually like this:
1. In nitrogen_yaws_app.erl, set appmods to [{"/", wf_yaws}]
2. In wf_yaws.erl, if there is a static file at the requested path then return send back the file
Ngoc.
On Feb 9, 9:41 pm, Rusty Klophaus <
rkloph...@gmail.com> wrote:
> Good question.
>
> Yes, currently Nitrogen catches everything under "/web". This decision
> was made to put all three HTTP servers (Yaws, Mochiweb, and Inets) on
> a level playing field.
>
> The reason is that while Mochiweb and Inets give you an opportunity to
> inspect and handle every incoming request, Yaws instead makes you
> assign a specific handler to a path, and will treat everything else as
> a request for a flat file.
>
> There is definitely work being done to allow you to hook into the
> Mochiweb or Inets loop to override this behavior. Tom McNulty is
> leading the charge here.
>
> Best,
> Rusty
>
> On Feb 9, 2009, at 1:03 AM, pmahoney wrote:
>
>
>
> > Hello, Nitrogen beginner here.
>
> > It seems, based on wf_inets:do/1 and nitrogen_mochiweb_app:loop/2 that
> > only URLs of "/" or "/web" ++ _ are valid "nitrogen framework" URLs.
> > Everything else results in an attempt to serve a static file (or a
> > 404).
>
> > Is this an intentional design decision?
>
> > If not, what are some ways it might be changed?
>
> > nitrogen:route/1 calls wf_utils:path_to_module/1 which splits
> > arbitrary URLs into {Module, PathInfo} if the module is loaded,
> > otherwise it returns {web_404, PathInfo}.
>
> > One option would be to check the route first, and only attempt to
> > serve a static file if {web_404, _} is returned. The route check is
> > performed for every request with inets, but only for requests that
> > don't match "web/" with mochiweb. Is the operation too expensive to
> > perform every time? (If so, a fairly minor patch to wf_inets.erl
> > would only call wf_platform:route/1 if Path matched "/web" ++ _).
>
> > From an aesthetic point of view, prefixing all URLs with "/web" is
> > somewhat ugly, but I suppose in the end it's mostly irrelevant.
>
> > Thanks.