Select Git revision
http_server.cpp
http_server.cpp 22.40 KiB
// #include <cpprest/http_msg.h>
#include <crow.h>
#include "crow/query_string.h"
#include "extern/tartanllama/optional.h"
#include "extern/websocketpp/websocketpp/frame.hpp"
#include "json_serializer.h"
#include "parameters.h"
#include "stopwatch_helper.h"
#include <algorithm>
#include <chrono>
#include <cstdint>
#include <functional>
#include <iostream>
#include <limits>
#include <regex>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <crow/app.h>
#include <crow/http_request.h>
#include <crow/http_response.h>
#include "http_server.hpp"
// #include "extern/websocketpp/websocketpp/roles/server_endpoint.hpp"
#include <rapidjson/document.h>
#include <rapidjson/prettywriter.h>
#include <rapidjson/rapidjson.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
#include <spdlog/fmt/chrono.h>
#include <spdlog/fmt/ranges.h>
#include <spdlog/spdlog.h>
#include <spdlog/stopwatch.h>
#include <unistd.h>
#include "flatbuffers/flatbuffer_builder.h"
#include "kernel_manager.h"
#include "nest_time.h"
#include "schema_generated.h"
#include "serialize.hpp"
#include "storage/data_storage.hpp"
#include "storage/spikedetector_storage.hpp"
// #define ASIO_STANDALONE
// #define _WEBSOCKETPP_CPP11_STRICT_
// #include <websocketpp/config/asio_no_tls.hpp>
// #include <websocketpp/client.hpp>
/* #include "rapidjson/" */
#define CROW_ROUTE_LAMBA(APP, ENDPOINT, FUNCTION) CROW_ROUTE(APP, ENDPOINT)([this](const crow::request& request) { return FUNCTION(request); });
namespace flatbuffers {
static Test::Foo::Spikes32 Pack32(const insite::Spike32& spike) {
return Test::Foo::Spikes32{spike.simulation_time, spike.node_id};
};
static Test::Foo::Spikes Pack(const insite::Spike& spike) {
return Test::Foo::Spikes{spike.simulation_time, spike.node_id};
};
} // namespace flatbuffers
namespace insite {
std::map<int, int> HttpServer::run_no;
int HttpServer::user_id = 0;
bool HttpServer::prepare_finished = false;
HttpServer::HttpServer(std::string address, DataStorage* storage)
: storage_(storage) {