/* Loadable module initialization */ PUBLIC int maOpenDirHandler(Http *http) { HttpStage *handler; MaAppweb *appweb; Dir *dir; if ((handler = httpCreateHandler(http, "dirHandler", NULL)) == 0) { return MPR_ERR_CANT_CREATE; } if ((handler->stageData = dir = mprAllocObj(Dir, manageDir)) == 0) { return MPR_ERR_MEMORY; } handler->start = startDir; http->dirHandler = handler; dir->sortOrder = 1; /* Declare configuration file directives */ appweb = httpGetContext(http); maAddDirective(appweb, "IndexOrder", indexOrderDirective); maAddDirective(appweb, "indexOptions", indexOptionsDirective); maAddDirective(appweb, "Options", optionsDirective); return 0; }
/* Loadable module initialization */ PUBLIC int maCgiHandlerInit(Http *http, MprModule *module) { HttpStage *handler, *connector; MaAppweb *appweb; if ((handler = httpCreateHandler(http, "cgiHandler", module)) == 0) { return MPR_ERR_CANT_CREATE; } http->cgiHandler = handler; handler->close = closeCgi; handler->outgoingService = cgiToBrowserService; handler->incoming = browserToCgiData; handler->open = openCgi; handler->start = startCgi; if ((connector = httpCreateConnector(http, "cgiConnector", module)) == 0) { return MPR_ERR_CANT_CREATE; } http->cgiConnector = connector; connector->outgoingService = browserToCgiService; connector->incoming = cgiToBrowserData; /* Add configuration file directives */ appweb = httpGetContext(http); maAddDirective(appweb, "Action", actionDirective); maAddDirective(appweb, "ScriptAlias", scriptAliasDirective); maAddDirective(appweb, "CgiEscape", cgiEscapeDirective); maAddDirective(appweb, "CgiPrefix", cgiPrefixDirective); return 0; }
/* Module load initialization. This is called when the module is first loaded. */ int maSimpleModuleInit(Http *http, MprModule *mp) { HttpStage *stage; MaAppweb *appweb; /* Create a stage so we can process configuration file data */ if ((stage = httpCreateStage(http, "simpleModule", HTTP_STAGE_MODULE, mp)) == 0) { return MPR_ERR_CANT_CREATE; } appweb = httpGetContext(http); maAddDirective(appweb, "CustomConfigKey", customConfigKey); return 0; }
PUBLIC int maProxyHandlerInit(Http *http, MprModule *module) { HttpStage *handler; MaAppweb *appweb; if ((handler = httpCreateHandler(http, module->name, 0, module)) == 0) { return MPR_ERR_CANT_CREATE; } handler->open = openProxy; handler->close = closeProxy; handler->incomingData = incomingProxyData; handler->outgoingService = outgoingProxyService; handler->start = startProxy; handler->ready = readyProxy; handler->process = processProxy; appweb = httpGetContext(http); maAddDirective(appweb, "Proxy", proxyDirective); return 0; }
/* Dynamic module initialization */ int maOpenDirHandler(Http *http) { HttpStage *handler; MaAppweb *appweb; Dir *dir; if ((handler = httpCreateHandler(http, "dirHandler", HTTP_STAGE_GET | HTTP_STAGE_HEAD, NULL)) == 0) { return MPR_ERR_CANT_CREATE; } if ((handler->stageData = dir = mprAllocObj(Dir, manageDir)) == 0) { return MPR_ERR_MEMORY; } handler->match = maMatchDir; handler->process = processDir; http->dirHandler = handler; dir->sortOrder = 1; appweb = httpGetContext(http); maAddDirective(appweb, "IndexOrder", indexOrderDirective); maAddDirective(appweb, "indexOptions", indexOptionsDirective); maAddDirective(appweb, "Options", optionsDirective); return 0; }