-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalSecureServer.cpp
More file actions
37 lines (29 loc) · 1.06 KB
/
LocalSecureServer.cpp
File metadata and controls
37 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "LocalSecureServer.h"
LocalSecureServer::LocalSecureServer(std::queue<Event*>* eventqueue) : server(443) {
this->eventqueue = eventqueue;
}
void LocalSecureServer::startServer() {
Serial.println("Configuring Server");
server.getServer().setRSACert(new BearSSL::X509List(serverCert), new BearSSL::PrivateKey(serverKey));
server.on("/", [this](){
server.send(200, "text/plain", "Hello world!");
});
server.on("/trigger/", [this](){
String button = server.arg("value");
this->eventqueue->push(new Event(button));
server.sendHeader("Location", String(REDIRECT_URL), true);
server.send(301, "text/plain", "");
});
server.on("/makro/", [this](){
String button = server.arg("value");
String modifier = server.arg("modifier");
this->eventqueue->push(new Event(button, modifier));
server.sendHeader("Location", String(REDIRECT_URL), true);
server.send(301, "text/plain", "");
});
server.begin();
Serial.println("HTTPS server started");
}
void LocalSecureServer::handleRequest() {
server.handleClient();
}