rcpp_framework/core/request.h

54 lines
980 B
C
Raw Normal View History

2020-11-25 00:20:41 +01:00
#ifndef REQUEST_H
#define REQUEST_H
#include <mutex>
#include <vector>
2020-11-25 00:20:41 +01:00
#include <brynet/net/http/HttpFormat.hpp>
#include <brynet/net/http/HttpService.hpp>
2020-11-25 00:20:41 +01:00
#include "handler_instance.h"
2020-11-25 00:20:41 +01:00
using namespace brynet;
using namespace brynet::net;
using namespace brynet::net::http;
class Request {
public:
const HTTPParser *http_parser;
const HttpSession::Ptr *session;
2020-11-25 00:20:41 +01:00
HttpResponse *response;
uint32_t current_middleware_index;
HandlerInstance handler_instance;
std::vector<HandlerInstance> *middleware_stack;
std::string head;
std::string body;
2020-12-26 00:17:36 +01:00
std::string footer;
std::string compiled_body;
void compile_body();
void compile_and_send_body();
void next_stage();
void send();
void reset();
2020-11-25 00:20:41 +01:00
Request();
~Request();
2020-11-25 00:20:41 +01:00
};
class RequestPool {
public:
static Request *get_request();
static void return_request(Request *request);
2020-11-25 00:20:41 +01:00
RequestPool();
~RequestPool();
2020-11-25 00:20:41 +01:00
protected:
static std::mutex _mutex;
static std::vector<Request *> _requests;
2020-11-25 00:20:41 +01:00
};
#endif