2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#include "express/legacy/in/WebApp.h"
44#ifndef DOXYGEN_SHOULD_SKIP_THIS
46#include "log/Logger.h"
54using namespace express;
56static std::map<std::string, std::string>
jalousien = {{
"kueche",
"kueche"},
57 {
"strasse",
"strasse"},
58 {
"esstisch",
"esstisch"},
60 {
"schlafzimmer",
"schlafzimmer"},
61 {
"arbeitszimmer",
"arbeitszimmer"},
62 {
"comfort",
"komfort"},
65static std::map<std::string, std::string>
actions = {{
"open",
"up"}, {
"close",
"down"}, {
"stop",
"stop"}};
67int main(
int argc,
char* argv[]) {
70 legacy::in::WebApp webApp
("werema");
74 webApp.get(
"/jalousien/:id", []
APPLICATION(req, res) {
75 VLOG(1) <<
"Param: " << req->
param("id");
76 VLOG(1) <<
"Qurey: " << req->
query("action");
80 int ret = system(arguments.c_str());
81 ret = (ret >> 8) & 0xFF;
83
84
85
86
104 const core::socket::
State& state) {
107 VLOG(1) << instanceName <<
": listening on '" << socketAddress
.toString() <<
"'";
110 VLOG(1) << instanceName <<
": disabled";
113 LOG(ERROR) << instanceName <<
": " << socketAddress
.toString() <<
": " << state
.what();
116 LOG(FATAL) << instanceName <<
": " << socketAddress
.toString() <<
": " << state
.what();
#define APPLICATION(req, res)
Config & getConfig() const
static constexpr int DISABLED
static constexpr int ERROR
static constexpr int FATAL
const std::string & query(const std::string &key) const
const std::string & param(const std::string &id, const std::string &fallBack="")
void send(const std::string &chunk)
Response & status(int status)
WebAppT(const std::string &name)
static void init(int argc, char *argv[])
static int start(const utils::Timeval &timeOut={LONG_MAX, 0})
const std::string & getInstanceName() const
std::string toString(bool expanded=true) const override
void listen(uint16_t port, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
int main(int argc, char *argv[])
static std::map< std::string, std::string > jalousien
static std::map< std::string, std::string > actions