PackageDescription: SwazooPragmaResourceDemo


Swazoo Pragma Resource Demo

Last published: May 24, 2012 by 'shaffer'

Defines 2 Classes
Extends 2 Classes


I contain a demo for the SwazooPragmaResource package. Look at the class PragmaResourceDemo for details. Register the demo with a Swazoo server as follows:

Use the next line to clean up your Swazoo server if you're uncertain how things are being resolved:

Swazoo.SwazooServer singleton stop; removeAllSites.

Define the demo site as the root URL as follows:

|site|
site := (Swazoo.SwazooServer singleton siteNamed: 'pragmaResource') ifNil: [Swazoo.SwazooSite newNamed: 'pragmaResource'].
site host: '*' port: 8889.
site addResource:
(SwazooPragmaResource.PragmaResourceDemo uriPattern: '/').
site start.

Then visit the following urls:

http://localhost:8889/index.html --- this fires the #index method. The form on the resulting page targets (action=) #methodAcceptingPost:
http://localhost:8889/assets/hello.html -- fires the #assets: method. That method looks up the remaining path element as an asset in PragmaResourceDemoAssets.
http://localhost:8889/zip/stuff/zip_hello.html -- fires the #zip: method which, in turn, looks in the zip file returned by PragmaResourceDemoAssets class>>zipAsset: for a file called stuff/zip_hello.html
http://localhost:8889/contentTypeSet -- fires #contentTypeSet which shows how to specify the content type of the response when it isn't clear from the URI
http://localhost:8889/answerFullResponse -- fires #answerFullResponse which shows a method returning Swazoo.HTTPResponse rather than just a string or byte array