-
Notifications
You must be signed in to change notification settings - Fork 48
/
srv.h
46 lines (35 loc) · 830 Bytes
/
srv.h
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
38
39
40
41
42
43
44
45
46
#ifndef __SRV_H__
#define __SRV_H__
#include <sys/time.h>
#include <string>
#include <vector>
#include <cstdint>
#include <evhtp.h>
#include <openssl/sha.h>
#include "Market.h"
#define DEFAULT_DATASTORE_FN "obsrv.rocks"
struct HttpApiEntry {
bool authReq; // authentication req'd?
const char *path;
bool pathIsRegex;
evhtp_callback_cb cb;
bool wantInput;
bool jsonInput;
};
class ReqState {
public:
std::string body;
SHA256_CTX bodyHash;
std::vector<unsigned char> md;
std::string path;
struct timeval tstamp;
const struct HttpApiEntry *apiEnt;
ReqState() : md(SHA256_DIGEST_LENGTH) {
SHA256_Init(&bodyHash);
gettimeofday(&tstamp, NULL);
}
};
extern orderentry::Market market;
extern uint32_t nextOrderId;
bool reqPreProcessing(evhtp_request_t *req, ReqState *state);
#endif // __SRV_H__