Re: Zinc, servicing a full website

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Zinc, servicing a full website

Sven Van Caekenberghe-2
Hi Leo,

> On 14 Apr 2015, at 14:28, Leo Paniceres <[hidden email]> wrote:
>
> Hi Sven,
>
>     Thanks very much for your excellent Zinc package.
>
> Excuse me for contacting to your email, I couldn’t find the official support email list.

I much prefer answering question on the pharo-users ML, in CC.

> My problem is that I could not find a way to solve simultaneously file servicing and services.
>
> I have a small app that responds to a request via a GET, and I also need to include in the response a lot of static files in a directory.
>
> How can I integrate two delegates?
>
> (ZnStaticFileServerDelegate and ZnDefaultServerDelegate)

This is from an older answer, it should be applicable:

Multiple handlers can be combined in one server. For example, http://zn.stfx.eu serves static content and serves all Zinc demos, with the following config (part of the startup script):

| id logFile staticFileServerDelegate |

id := 1.

logFile := 'transcript.{1}.log' format: { id }.
(NonInteractiveTranscript onFileNamed: logFile) install.

(ZnServer defaultOn: 8080 + id)
       logToTranscript;
       route: 'r', id printString;
       start.

(staticFileServerDelegate := ZnStaticFileServerDelegate new)
       prefixFromString: 'zn';
       directory: '/home/ubuntu/zn' asFileReference.

ZnServer default delegate prefixMap
       at: 'zn'
       put: [ :request | staticFileServerDelegate handleRequest: request ];
       at: 'redirect-to-zn'
       put: [ :request | ZnResponse redirect: '/zn/index.html' ];
       at: '/'
       put: 'redirect-to-zn'.

HTH,

Sven

> --
>
> Afectuosamente​ desde Argentina​, (de corazón por mas que lo tenga automatico)
> Leo