adapt to latest changes, use generic request handlers.
This commit is contained in:
@@ -51,18 +51,22 @@ void AQH_ModDataClient_Extend(AQH_MODULE *m, AQH_SERVICE *sv, const char *baseFo
|
||||
|
||||
|
||||
|
||||
int AQH_ModDataClient_HandleRequest(AQH_MODULE *m, AQCGI_REQUEST *rq, AQH_SESSION *session, AQH_MODDATACLIENT_RUN_FN runFn)
|
||||
void AQH_ModDataClient_HandleRequest(AQH_MODULE *m,
|
||||
AQCGI_REQUEST *rq,
|
||||
AQH_SESSION *session,
|
||||
AQH_MODDATACLIENT_RUN_FN runFn,
|
||||
GWEN_BUFFER *dbuf)
|
||||
{
|
||||
AQH_EVENT_LOOP *eventLoop;
|
||||
AQH_DATACLIENT *dc;
|
||||
GWEN_BUFFER *dbuf;
|
||||
int rv;
|
||||
|
||||
rv=AQH_Init();
|
||||
if (rv<0) {
|
||||
DBG_ERROR(NULL, "here (%d)", rv);
|
||||
AQCGI_SendResponseWithStatus(rq, 500, "Internal Error");
|
||||
return rv;
|
||||
AQCGI_Request_SetResponseCode(rq, 500);
|
||||
AQCGI_Request_SetResponseText(rq, "Internal Error");
|
||||
return;
|
||||
}
|
||||
|
||||
eventLoop=AQH_EventLoop_new();
|
||||
@@ -70,9 +74,9 @@ int AQH_ModDataClient_HandleRequest(AQH_MODULE *m, AQCGI_REQUEST *rq, AQH_SESSIO
|
||||
rv=AQH_DataClient_ReadConfigFile(dc);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(NULL, "here (%d)", rv);
|
||||
AQCGI_SendResponseWithStatus(rq, 500, "Internal Error");
|
||||
AQH_Session_free(session);
|
||||
return rv;
|
||||
AQCGI_Request_SetResponseCode(rq, 500);
|
||||
AQCGI_Request_SetResponseText(rq, "Internal Error");
|
||||
return;
|
||||
}
|
||||
|
||||
rv=AQH_DataClient_ConnectWithArgs(dc, 0);
|
||||
@@ -80,25 +84,18 @@ int AQH_ModDataClient_HandleRequest(AQH_MODULE *m, AQCGI_REQUEST *rq, AQH_SESSIO
|
||||
DBG_ERROR(NULL, "Error connecting (%d)", rv);
|
||||
AQH_DataClient_free(dc);
|
||||
AQH_EventLoop_free(eventLoop);
|
||||
AQCGI_SendResponseWithStatus(rq, 500, "Internal Error");
|
||||
AQH_Session_free(session);
|
||||
return GWEN_ERROR_GENERIC;
|
||||
AQCGI_Request_SetResponseCode(rq, 500);
|
||||
AQCGI_Request_SetResponseText(rq, "Internal Error");
|
||||
return;
|
||||
}
|
||||
|
||||
dbuf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||
AQH_ModService_AddHeader(m, "en", dbuf);
|
||||
if (runFn)
|
||||
runFn(m, rq, session, dc, dbuf);
|
||||
AQH_ModService_AddFooter(m, "en", dbuf);
|
||||
AQCGI_Request_SetBufferResponseBody(rq, dbuf);
|
||||
AQCGI_Request_AddResponseHeaderData(rq, "Content-type: text/html");
|
||||
|
||||
AQH_DataClient_free(dc);
|
||||
AQH_EventLoop_free(eventLoop);
|
||||
AQH_Session_free(session);
|
||||
|
||||
AQH_Fini();
|
||||
return AQCGI_SendResponse(rq);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user