> Hi, I'm trying to walk through the entry point of an ErlyWeb app and
> I'm having trouble determining how that www/index.html is reached.
> When a request come in for the root of the application, no components,
> what happens?
A request comes in that hits yaws, who sees that erlyweb is registered
as the application for a given path (in yaws.conf), and passes control
to erlyweb. Erlyweb is configured (though an "opaque" parameter in
yaws.conf) to call your application at myapp_app_controller:hook/1.
That function returns an {ewc} or other erlyweb tuple that probably
define some function to call to get data, or more {ewc} tuples, and so
on.
In hook/1, you do something like:
Ewc = erlyweb:get_initial_ewc({ewc, A1}),
That returns either an {ewc} tuple (or other type, like {ewr},
{phased,Ewc}, etc), or a {page,Page} tuple. The Page variable here
contains a file-name to load, relative to www/.
For example, here's my wrotit_app_controller:hook/1:
------ wrotit_app_controller:hook/1 ------
hook(A) ->
%% render /post/index for /
A1=case yaws_arg:appmoddata(A) of
Root when (Root =:= "") or (Root =:= "/") ->
yaws_arg:appmoddata(A, "/post/popular");
_ ->
A
end,
Ewc = erlyweb:get_initial_ewc({ewc, A1}),
case Ewc of
{page,_}=Page ->
Page;
_ ->
{phased, Ewc,
fun(_Ewc, Data,_PhasedVars) ->
{ewc, html_container, index, [A1,
{data, Data}]}
end}
end.
So a request for a CSS file www/ will result in
erlyweb:get_initial_ewc/1 returning a {page,"/style.css"}, which
erlyweb will then read and return the contents of.
I hope that makes sense :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"erlyweb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---