[erlang-questions] Code organization for virtual websites based on Cowboy

Loïc Hoguin essen@REDACTED
Sun Apr 27 19:59:33 CEST 2014


Hi,

Sorry for the late reply, I had to think a little about it.

I would have a single application for all handlers.

I would create two folders under src, one per host. For example:

  src/www
  src/chat

Static files I would probably want to have a specific host for them so I 
wouldn't need to separate (I could create extra folders for the 
host-specific stuff, but there's no reason to separate jquery and others).

On initialization I would have the file src/my_app.erl call a predefined 
function for each host to get their routing rules, for example 
www_routes:get() ++ chat_routes:get().

I would make sure that I only have handlers or helpers in this 
application. I would make separate applications for different parts of 
the system, for example an application for managing sessions, an 
application for chat communication, an application for www business 
logic, etc. and I would call these applications from the handlers.

Does this answer your question?

On 04/25/2014 12:52 AM, lloyd@REDACTED wrote:
> Hello,
>
> Suppose we have n virtual websites served out of a single Cowboy server.
>
> I get, I think, this:
>
> Routes = [Host1, Host2, ... HostN].
> Host1 = {HostMatch, PathsList}.
> Host2 = {HostMatch, Constraints, PathsList}.
>
> But two questions trouble me:
>
> 1) What is the best directory structure to organize handlers and site-specific code to keep site code and resources separated and and easy to maintain?
>
> 2) Can these sites be developed and tested through localhost, or is a more elaborate set-up involving, say more than one box on a local network with local DNS server?
>
> Many thanks,
>
> LRP
>
>
> *********************************************
> My books:
>
> THE GOSPEL OF ASHES
> http://thegospelofashes.com
>
> Strength is not enough. Do they have the courage
> and the cunning? Can they survive long enough to
> save the lives of millions?
>
> FREEIN' PANCHO
> http://freeinpancho.com
>
> A community of misfits help a troubled boy find his way
>
> AYA TAKEO
> http://ayatakeo.com
>
> Star-crossed love, war and power in an alternative
> universe
>
> Available through Amazon or by request from your
> favorite bookstore
>
>
> **********************************************
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>

-- 
Loïc Hoguin
http://ninenines.eu



More information about the erlang-questions mailing list