--- Begin Message ---
Thanks Sven, crystal clear!
Davide

Sven Van Caekenberghe-2 wrote
> Hi Davide,
> 
> What Norbert says is all correct and useful. Go read the code of the
> classes he mentions.
> 
> I wanted to add, that fundamentally, all this (dispatching/configuring),
> is not difficult to understand or to follow.
> 
> Even with the aptly named ZnDefaultServerDelegate you can already do a
> lot, including what you asked for. Consider part of the startup file of
> http://zn.stfx.eu which serves its own website, together with all the
> default builtin responses.
> 
> So the following are all possible:
> 
> - http://zn.stfx.eu
> - http://zn.stfx.eu/zn/index.html
> - http://zn.stfx.eu/xn/small.html
> - http://zn.stfx.eu/welcome
> - http://zn.stfx.eu/dw-bench
> - ...
> - http://zn.stfx.eu/help
> 
> (the last one lists all configured prefixes).
> 
> (ZnServer defaultOn: 8180)
>   logToTranscript;
>   logLevel: 1;
>   start.
> 
> (staticFileServerDelegate := ZnStaticFileServerDelegate new)
>   prefixFromString: 'zn'; 
>   directory: '/home/stfx/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'.
> 
> (#map:to: is newer/better)
> 
> When using a block as a handler, you can literally do anything.
> 
> HTH,
> 
> Sven
> 
>> On 28 Mar 2020, at 08:54, Norbert Hartl <

> norbert@

> > wrote:
>> 
>> There is ZnPrefixMappingDelegate you can use.
>> 
>> server
>>    delegate: (ZnPrefixMappingDelegate
>>       map: 'static' to: staticFileDelegate; 
>>       map: 'app' to: myApp).
>> 
>> There is also ZnStaticFileDecoratorDelegate if you want to mimick another
>> typical setup where all urls that resolve to a file get served from disk
>> and any other will be forwarded to you app.
>> 
>> server
>>    delegate: (ZnStaticFileDecoratorDelegate
>>       decorate: myApp
>>       servingFilesFrom: 'static/').
>> 
>> Hope this helps!
>> 
>> Norbert
>> 
>> 
>>> Am 28.03.2020 um 01:34 schrieb Davide Varvello via Pharo-users <

> pharo-users@.pharo

> >:
>>> 
>>> 
>>> Von: Davide Varvello <

> varvello@

> >
>>> Betreff: Zinc server with static and non-static files
>>> Datum: 28. März 2020 um 01:34:13 MEZ
>>> An: 

> pharo-users@.pharo

>>> 
>>> 
>>> Hi Guys,
>>> Is it possible a Zinc server returns static files within a specific url
>>> path
>>> (like the ZnStaticFileServerDelegate) and also returns other logics as
>>> shown
>>> with map:#otherPath to: MyWebapp new ?
>>> TIA
>>> Davide
>>> 
>>> 
>>> 
>>> --
>>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>>> 
>>> 
>>> 
>>





--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html


--- End Message ---

Reply via email to