Skip to content

Commit

Permalink
[webui] #ifdef atari-only (for now) endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
nwah authored and tschak909 committed Feb 13, 2025
1 parent dab50fd commit 63aae3e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/http/httpService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,7 @@ esp_err_t fnHttpService::get_handler_slot(httpd_req_t *req)
return ESP_OK;
}

#ifdef BUILD_ATARI
esp_err_t fnHttpService::get_handler_hosts(httpd_req_t *req)
{
std::string response = "";
Expand Down Expand Up @@ -1211,6 +1212,7 @@ esp_err_t fnHttpService::post_handler_hosts(httpd_req_t *req)
httpd_resp_send(req, response.c_str(), response.length());
return ESP_OK;
}
#endif

std::string fnHttpService::shorten_url(std::string url)
{
Expand Down Expand Up @@ -1508,6 +1510,7 @@ httpd_handle_t fnHttpService::start_server(serverstate &state)
.is_websocket = false,
.handle_ws_control_frames = false,
.supported_subprotocol = nullptr},
#ifdef BUILD_ATARI
{.uri = "/hosts",
.method = HTTP_GET,
.handler = get_handler_hosts,
Expand All @@ -1522,6 +1525,7 @@ httpd_handle_t fnHttpService::start_server(serverstate &state)
.is_websocket = false,
.handle_ws_control_frames = false,
.supported_subprotocol = nullptr},
#endif
{.uri = "/url/*",
.method = HTTP_GET,
.handler = get_handler_shorturl,
Expand Down
2 changes: 2 additions & 0 deletions lib/http/httpService.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ class fnHttpService
static esp_err_t get_handler_eject(httpd_req_t *req);
static esp_err_t get_handler_dir(httpd_req_t *req);
static esp_err_t get_handler_slot(httpd_req_t *req);
#ifdef BUILD_ATARI
static esp_err_t get_handler_hosts(httpd_req_t *req);
static esp_err_t post_handler_hosts(httpd_req_t *req);
#endif
static esp_err_t get_handler_shorturl(httpd_req_t *req);

#ifdef BUILD_ADAM
Expand Down
4 changes: 4 additions & 0 deletions lib/http/mgHttpService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ int fnHttpService::get_handler_eject(mg_connection *c, mg_http_message *hm)
return 0;
}

#ifdef BUILD_ATARI
int fnHttpService::get_handler_hosts(mg_connection *c, mg_http_message *hm)
{
std::string response = "";
Expand All @@ -510,6 +511,7 @@ int fnHttpService::post_handler_hosts(mg_connection *c, mg_http_message *hm)
mg_http_reply(c, 200, "", "%s", response.c_str());
return 0;
}
#endif

std::string fnHttpService::shorten_url(std::string url)
{
Expand Down Expand Up @@ -631,12 +633,14 @@ void fnHttpService::cb(struct mg_connection *c, int ev, void *ev_data)
fnSystem.reboot(500, true); // deferred exit with code 75 -> should be started again
}
}
#ifdef BUILD_ATARI
else if (mg_http_match_uri(hm, "/hosts")) {
if (mg_vcasecmp(&hm->method, "POST") == 0)
post_handler_hosts(c, hm);
else
get_handler_hosts(c, hm);
}
#endif
else if (mg_http_match_uri(hm, "/url/*"))
{
get_handler_shorturl(c, hm);
Expand Down

0 comments on commit 63aae3e

Please sign in to comment.