JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
JodaQueryRequest.h
Go to the documentation of this file.
1 
2 //
3 // Created by Nico on 22/08/2019.
4 //
5 
6 #ifndef JODA_JODAQUERYREQUEST_H
7 #define JODA_JODAQUERYREQUEST_H
8 
9 #include <httplib.h>
10 #include <joda/misc/Benchmark.h>
12 
13 namespace joda::network::apiv2 {
14 
20  public:
26  static void registerEndpoint(const std::string &prefix,
27  httplib::Server &server);
28 
29  private:
30  static constexpr auto endpoint = "/query";
31 
32  static void query(const httplib::Request &req, httplib::Response &res);
33  static void success_(unsigned long result, httplib::Response &res,
34  const Benchmark &benchmark);
35  static void export_(httplib::Response &res);
36  static void empty_(httplib::Response &res);
37  static void skipped_(httplib::Response &res);
38  static void error_(unsigned long code, httplib::Response &res);
39  static RJDocument successDocument(unsigned long result, int64_t size,
40  const std::string &message,
41  const Benchmark * = nullptr);
42 
43 };
44 
46  public:
47  JodaQueryException() : JodaAPIException("Missing 'Query' parameter") {}
48 
49  explicit JodaQueryException(const std::string &what)
50  : JodaAPIException("'Query' parameter invalid: " + what) {}
51 };
52 
54  public:
57  "A unknown error happened, check server logs for information.") {}
58 };
59 
61  public:
64  "The server skipped the query because of an error. Check logs") {}
65 };
66 } // namespace joda::network::apiv2
67 
68 #endif // JODA_JODAQUERYREQUEST_H
rapidjson::GenericDocument< RJChar, RJMemoryPoolAlloc, RJBaseAlloc > RJDocument
Definition: RJFwd.h:28
Definition: Benchmark.h:27
Definition: JodaServer.h:18
Definition: JodaQueryRequest.h:45
JodaQueryException(const std::string &what)
Definition: JodaQueryRequest.h:49
JodaQueryException()
Definition: JodaQueryRequest.h:47
Definition: JodaQueryRequest.h:19
static void registerEndpoint(const std::string &prefix, httplib::Server &server)
Definition: JodaQueryRequest.cpp:14
Definition: JodaQueryRequest.h:60
JodaQuerySkippedException()
Definition: JodaQueryRequest.h:62
JodaQueryUnkownErrorException()
Definition: JodaQueryRequest.h:55
Definition: API.h:10