[Seaside-dev] Re: ZnSeasideStaticServerAdaptorDelegate

Johan Brichau johan at inceptive.be
Thu Sep 22 08:06:00 UTC 2016


Hi Sven,

Refined it a little bit more (only try to get a file when it’s a GET request).
Don’t know if there is a more elegant way of doing that but because this adaptor should really only be used in development, it does not matter a lot.

Can you change the package or can we upload it?

thx
Johan

handleRequest: znRequest
	"If the Seaside request processing apparatus returns an HTTP response with a 'not found' error for a GET request,
	check the filesystem for a file that matches the uri of the request, if found send the file if not send the original error."

	| response staticResponse |
	response := self adaptor process: znRequest.
	^ (response isNotFound and: [ (znRequest method = 'GET') and: [ response isAuthenticationRequired not ] ])
			ifTrue: [ 
				staticResponse := self staticDelegate handleRequest: znRequest.
				staticResponse isNotFound ifTrue:[ response ] ifFalse:[ staticResponse ] ]
			ifFalse: [ response ].

> On 22 Sep 2016, at 09:38, Sven Van Caekenberghe <sven at stfx.eu> wrote:
> 
> Hi Johan,
> 
> The original code was a bit of a hack, IMHO, but your solution makes way more sense, because it is more specific, so OK for me.
> 
> Sven
> 
>> On 22 Sep 2016, at 09:32, Johan Brichau <johan at inceptive.be> wrote:
>> 
>> Hi all, (cc: Sven)
>> 
>> I just started to use the ZnSeasideStaticServerAdaptorDelegate to replace our uses of Seaside-Filesystem (exposing external file directories in Seaside handlers) in the development environment.
>> The Zinc solution is really better, but I noticed it is a bit too liberal about throwing away error responses coming from the Seaside backend. 
>> 
>> Our application (and its API, which is a separate handler) responds different errors which should really be answered to the client.
>> The ZnSeasideStaticServerAdaptorDelegate tries to look for a file upon _any_ error coming from the Seaside backend and will eventually yield a 404 because it cannot find a file for the given url either.
>> 
>> I propose to change the code as shown below. A file should only be searched when the Seaside backend responds a 404 and if the file was not found, we just return the original error response.
>> This yields the expected behaviour in our case, which I think is not specific to our application.
>> 
>> What do you think?
>> 
>> Cheers
>> Johan
>> 
>> 
>> handleRequest: znRequest
>> 	"If the Seaside request processing apparatus returns an HTTP response with a 'not found' error
>> 	check the filesystem for a file that matches the uri of the request, if found send the file if not send the original error."
>> 
>> 	| response staticResponse |
>> 	response := self adaptor process: znRequest.
>> 	^ (response isNotFound and: [ response isAuthenticationRequired not ])
>> 			ifTrue: [ 
>> 				staticResponse := self staticDelegate handleRequest: znRequest.
>> 				staticResponse isNotFound ifTrue:[ response ] ifFalse:[ staticResponse ] ]
>> 			ifFalse: [ response ].
> 



More information about the seaside-dev mailing list