Erlang/OTP Forums

Author Message

<  Erlyweb mailing list  ~  www/index.html

Guest
Posted: Sun Mar 23, 2008 5:19 pm Reply with quote
Guest
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?

Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
ketralnis
Posted: Mon Mar 24, 2008 3:52 am Reply with quote
User Joined: 20 Jul 2007 Posts: 151 Location: San Francisco, CA
> 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 Smile

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message AIM Address

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum