Log api
This commit is contained in:
parent
49415c4173
commit
8984dcb4c5
2 changed files with 5 additions and 6 deletions
|
@ -16,8 +16,8 @@ namespace fw
|
||||||
this->serverCache = new ServerSessions(5);
|
this->serverCache = new ServerSessions(5);
|
||||||
#endif
|
#endif
|
||||||
this->setup_routing(cert, key);
|
this->setup_routing(cert, key);
|
||||||
Serial.printf("Starting server on port %i...\n", port);
|
|
||||||
this->server->begin();
|
this->server->begin();
|
||||||
|
Serial.printf("%s listening on port %i\n", log, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
API::~API()
|
API::~API()
|
||||||
|
@ -43,13 +43,13 @@ namespace fw
|
||||||
{
|
{
|
||||||
if (!username || *username == 0x00 || strlen(username) > CREDENTIALS_LENGTH)
|
if (!username || *username == 0x00 || strlen(username) > CREDENTIALS_LENGTH)
|
||||||
{
|
{
|
||||||
Serial.println("Username too long or missing!");
|
Serial.printf("%s Username too long or missing!\n", log);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
strncpy(credentials.username, username, CREDENTIALS_LENGTH);
|
strncpy(credentials.username, username, CREDENTIALS_LENGTH);
|
||||||
if (!password || *password == 0x00 || strlen(password) > CREDENTIALS_LENGTH)
|
if (!password || *password == 0x00 || strlen(password) > CREDENTIALS_LENGTH)
|
||||||
{
|
{
|
||||||
Serial.println("Password too long or missing!");
|
Serial.printf("%s Password too long or missing!\n", log);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
strncpy(credentials.password, password, CREDENTIALS_LENGTH);
|
strncpy(credentials.password, password, CREDENTIALS_LENGTH);
|
||||||
|
@ -116,9 +116,7 @@ namespace fw
|
||||||
|
|
||||||
void API::not_found_handler()
|
void API::not_found_handler()
|
||||||
{
|
{
|
||||||
this->json_message_response(
|
this->json_message_response("see " + get_url_base() + "/api for available routes", 404);
|
||||||
"see " + get_url_base() + "/api for available routes",
|
|
||||||
404);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::get_endpoint_list_handler()
|
void API::get_endpoint_list_handler()
|
||||||
|
|
|
@ -33,6 +33,7 @@ namespace fw
|
||||||
String api_ip = "0.0.0.0";
|
String api_ip = "0.0.0.0";
|
||||||
uint16_t api_port;
|
uint16_t api_port;
|
||||||
String json_response_type = "application/json; charset=utf-8";
|
String json_response_type = "application/json; charset=utf-8";
|
||||||
|
String log = "[API]";
|
||||||
|
|
||||||
String get_url_base();
|
String get_url_base();
|
||||||
ok_t setup_auth(const char *username, const char *password);
|
ok_t setup_auth(const char *username, const char *password);
|
||||||
|
|
Reference in a new issue