1 // $Id: ApacheWO+RequestHandler.m,v 1.1 2004/06/08 11:06:00 helge Exp $
4 #include "AWODirectoryConfig.h"
5 #include "ApacheResourceManager.h"
6 #include "WORequest+Apache.h"
7 #include "WOResponse+Apache.h"
9 #include <NGObjWeb/WOApplication.h>
10 #include <NGObjWeb/WORequestHandler.h>
11 #include <ApacheAPI/ApacheAPI.h>
14 implements a WORequestHandler "dispatcher"
16 All WORequestHandler classes are registered in the ApacheHandlers.plist
17 with the single dispatchRequest: selector. This method creates an object
18 of the request handler class and let it dispatch the request.
21 @implementation ApacheWO(RequestHandler)
23 - (int)dispatchRequest:(ApacheRequest *)_rq
24 usingHandlerNamed:(NSString *)_hname
25 inApplication:(WOApplication *)_app
27 WORequestHandler *handler;
29 WOResponse *woResponse;
32 if ((handler = [_app requestHandlerForKey:_hname]) == nil) {
33 [self logWithFormat:@"did not find request handler for key '%@'",
35 return ApacheDeclineRequest;
38 woRequest = [[[WORequest alloc] initWithApacheRequest:_rq] autorelease];
40 woResponse = [_app dispatchRequest:woRequest usingHandler:handler];
45 result = [woResponse sendResponseUsingApacheRequest:_rq];
52 - (int)dispatchRequestHandler:(ApacheRequest *)_rq {
53 NSAutoreleasePool *pool;
54 AWODirectoryConfig *cfg;
59 return ApacheDeclineRequest;
61 pool = [[NSAutoreleasePool alloc] init];
63 /* get directory specific info (app, request-handler) ! */
65 cfg = [self configForDirectory:_rq];
67 if ((app = [cfg application]) == nil) {
68 [self logWithFormat:@"missing app .."];
72 result = [self dispatchRequest:_rq
73 usingHandlerNamed:[_rq handler]
79 /* say we are done ... */
83 @end /* ApacheWO(WoxPageHandler) */