From cb175e0b367226c965c3bb688ebc98ab85ffecd5 Mon Sep 17 00:00:00 2001 From: SciLor Date: Fri, 6 Sep 2024 18:45:41 +0000 Subject: [PATCH] Add tonies json reload API --- include/handler_api.h | 1 + src/handler_api.c | 7 +++++++ src/server.c | 1 + 3 files changed, 9 insertions(+) diff --git a/include/handler_api.h b/include/handler_api.h index 43b5bb98..303bdfc4 100644 --- a/include/handler_api.h +++ b/include/handler_api.h @@ -43,6 +43,7 @@ error_t handleApiAssignUnknown(HttpConnection *connection, const char_t *uri, co error_t handleApiPcmUpload(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx); error_t handleApiContent(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx); error_t handleApiContentDownload(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx); +error_t handleApiToniesJsonReload(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx); error_t handleApiToniesJson(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx); error_t handleApiToniesJsonUpdate(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx); error_t handleApiToniesCustomJson(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx); diff --git a/src/handler_api.c b/src/handler_api.c index a6a2c761..e3a0144e 100644 --- a/src/handler_api.c +++ b/src/handler_api.c @@ -2108,6 +2108,13 @@ error_t handleApiFileMove(HttpConnection *connection, const char_t *uri, const c return httpWriteResponseString(connection, message, false); } +error_t handleApiToniesJsonReload(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx) +{ + tonies_deinit(); + tonies_init(); + httpPrepareHeader(connection, "text/plain; charset=utf-8", 2); + return httpWriteResponseString(connection, "OK", false); +} error_t handleApiToniesJson(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx) { char *tonies_path = custom_asprintf("%s%c%s", settings_get_string("internal.configdirfull"), PATH_SEPARATOR, TONIES_JSON_FILE); diff --git a/src/server.c b/src/server.c index e74ac440..bf173bb6 100644 --- a/src/server.c +++ b/src/server.c @@ -132,6 +132,7 @@ request_type_t request_paths[] = { {REQ_GET, "/api/stats", SERTY_WEB, &handleApiStats}, {REQ_GET, "/api/toniesJsonSearch", SERTY_WEB, &handleApiToniesJsonSearch}, {REQ_GET, "/api/toniesJsonUpdate", SERTY_WEB, &handleApiToniesJsonUpdate}, + {REQ_GET, "/api/toniesJsonReload", SERTY_WEB, &handleApiToniesJsonReload}, {REQ_GET, "/api/toniesJson", SERTY_WEB, &handleApiToniesJson}, {REQ_GET, "/api/toniesCustomJson", SERTY_WEB, &handleApiToniesCustomJson}, {REQ_GET, "/api/tonieboxesJson", SERTY_WEB, &handleApiTonieboxJson},