Improved code sharing.
we now have a base url handler which handles listing, adding and editing any objects including permission management.
This commit is contained in:
71
apps/aqhome-storage/u_base.c
Normal file
71
apps/aqhome-storage/u_base.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "./u_base.h"
|
||||
#include "./aqhomehttp.h"
|
||||
#include "aqhome/http/httpservice_http.h"
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/i18n.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* defines
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* forward declarations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* implementations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_BaseHttpUrlHandler_CreateResponseForErrorCode(AQH_HTTP_URLHANDLER *uh,
|
||||
AQH_HTTP_REQUEST *rq,
|
||||
int rv,
|
||||
AQH_HTTP_URLHANDLER_WRITEPAGE_CB cb,
|
||||
GWEN_DB_NODE *db)
|
||||
{
|
||||
if (rv<0) {
|
||||
switch(rv) {
|
||||
case GWEN_ERROR_INVALID:
|
||||
return AQH_HttpUrlHandler_CreatePageMessage(uh, rq, "red", I18N("Missing fields"), 1, db, cb);
|
||||
case GWEN_ERROR_FOUND:
|
||||
return AQH_HttpUrlHandler_CreatePageMessage(uh, rq, "red", I18N("Object already exists"), 1, db, cb);
|
||||
case GWEN_ERROR_NOT_FOUND:
|
||||
return AQH_HttpUrlHandler_CreatePageMessage(uh, rq, "red", I18N("Object not found"), 1, db, cb);
|
||||
case GWEN_ERROR_IO:
|
||||
case GWEN_ERROR_INTERNAL:
|
||||
default:
|
||||
return AQH_HttpService_CreateResponseMsg(AQH_HttpUrlHandler_GetHttpService(uh),
|
||||
500, "Internal error",
|
||||
AQH_HttpRequest_GetProtocol(rq), NULL);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user