[aida] Custom request handling howto?
Janko Mivšek
janko.mivsek at eranova.si
Tue Nov 20 16:48:24 CET 2007
Hi Michael,
Michael Rueger wrote:
> after tinkering with Aida a bit I'm trying to setup a handler for a REST
> callback. I thought registering a Resource would do the trick, but it
> seems AIDA still goes through the motions of finding an App object for
> the Resource object.
Yes, because URL resolution is handled entirely by Aida's Url resolver
after request came to AIDASite. Method override AIDASite>>helpResolve:
is where Swazoo's Url resolution is stopped and handled by Aida instead.
> Am I overlooking something or is there currently no way to bypass this
> hardwired dispatching to object/app pairs?
I would start expanding AIDASite>>helpResolve: to try to resolve
sub-resources first and if can't be resolved there, then go to Aida for
final resolution. This would be easy to achieve, IMO.
So for instance if you'd like to use FileMappingResource for serving
static files instead of Aida, you'd add this resource to AIDASite and
set uriPatern (with 'files' for instance) to serve static files from
/files. Something like that.
> I could imagine that double dispatching the lookup could solve this
> problem, so registered objects/resources could bring their own custom
> request handling with them. Or introducing handler objects that define
> how the lookup and the request handling is done. So we could have
> handler objects for object/app pairs (maybe with additional scope), raw
> request handlers, etc...
> Suggestions? Ideas? Pointers?
I think the Url resolution can be extended in two ways:
- to extend Swazoo way of resolution also to the sub-resources of
AIDASite, as it is shown above,
- to extend Aida way of resolution. URLResolver resolve urls in three
levels already and this can be extended:
1. if Url is registered for some object, request is passed to
that object. This is normally a domain object which passes
it to its App (see Object>>printWebPageFor: session)
2. if not 1 then a static file is tried to be found
3. if not 2 then a so called method resource is searched for
Look URLResolver>>ooRefFromURL: for above resolution. In any case the
Url will be resolved to a pointer to some object, being domain object,
FileProxy or MethodResource, and request will be passed to it. This
object will also be registered in main URLResolver table at that time,
so that next time the resolution will be direct and fast.
To conclude, you can extend resolution in Aida way, which always resolve
to some object or in Swazoo way, which resolve to some Resource.
I hope I hit your question more or less with that answer...
Best regards
Janko
--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
More information about the Aida
mailing list