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"
43#include "express/middleware/JsonMiddleware.h"
45#ifndef DOXYGEN_SHOULD_SKIP_THIS
47#include "log/Logger.h"
49#include <nlohmann/json.hpp>
55int main(
int argc,
char* argv[]) {
56 using WebApp = express::legacy::
in::WebApp;
60 using SocketAddress = WebApp::SocketAddress;
62 const WebApp legacyApp
("legacy-jsonserver");
64 legacyApp.use(express::
middleware::JsonMiddleware());
71 VLOG(1) << instanceName <<
": listening on '" << socketAddress
.toString() <<
"'";
74 VLOG(1) << instanceName <<
": disabled";
85 legacyApp.post(
"/index.html", []
APPLICATION(req, res) {
86 std::string jsonString;
89 [&jsonString](nlohmann::json& json) {
90 jsonString = json.dump(4);
91 VLOG(1) <<
"Application received body: " << jsonString;
93 [](
const std::string& key) {
94 VLOG(1) << key <<
" attribute not found";
#define APPLICATION(req, res)
Config * getConfig() const
static constexpr int DISABLED
static constexpr int ERROR
static constexpr int FATAL
void send(const std::string &chunk)
WebAppT(const std::string &name)
static void init(int argc, char *argv[])
static int start(const utils::Timeval &timeOut={LONG_MAX, 0})
LogMessage(Level level, int verboseLevel=-1, bool withErrno=false)
const std::string & getInstanceName() const
std::string toString(bool expanded=true) const override
const Super & listen(uint16_t port, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
void getAttribute(const std::function< void(Attribute &)> &onFound, const std::function< void(const std::string &)> &onNotFound, const std::string &subKey="") const
int main(int argc, char *argv[])