;D Stef
On Jul 1, 2011, at 2:23 PM, Sven Van Caekenberghe wrote: > > On 01 Jul 2011, at 12:53, Janko Mivšek wrote: > >> Why not simply: >> >> (ZnServer startOn: 1337) >> onRequestRespond: [:request |: ZnResponse ok: 'Hello world'] >> >> >> This is the closest form to that node.js example and really show the >> power of Smalltalk and its closures. Also understandable to everyone >> including the (IMHO) majority, who don't understand design patterns like >> Delegate well. > > If you compare all the Zn delegates that are included, such as Nick's > ZnDispatcherDelegate, I think it is clear that #handleRequest: is a good > interface. Different use cases require delegate's with more or less features > and thus complexity. > > But for the sake of short/elegant examples, I added the > ZnSingleThreadedServer>>#onRequestRespond: convenience method, so the > examples now become: > > (ZnServer startDefaultOn: 1337) > onRequestRespond: [ :request | ZnResponse ok: (ZnEntity text: 'Hello > World!') ]. > > and > > (ZnServer startDefaultOn: 1337) > onRequestRespond: [ :request | ZnResponse ok: (ZnEntity with: request > contents) ]. > > Sven > > >
