2019-05-04 23:00:53 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <unordered_set>
|
|
|
|
|
|
2019-05-04 23:21:33 -07:00
|
|
|
#include "request.h"
|
2019-05-04 23:00:53 -07:00
|
|
|
|
|
|
|
|
namespace firecgi {
|
|
|
|
|
|
|
|
|
|
class Server {
|
|
|
|
|
public:
|
2019-05-07 22:56:00 -07:00
|
|
|
Server(int port, const std::function<void(Request*)>& callback, int threads=1, const std::unordered_set<std::string_view>& headers={});
|
2019-05-04 23:00:53 -07:00
|
|
|
void Serve();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void NewConn(int listen_sock, int epoll_fd);
|
|
|
|
|
int NewListenSock();
|
|
|
|
|
void ServeInt();
|
|
|
|
|
|
|
|
|
|
const int port_;
|
2019-05-07 22:56:00 -07:00
|
|
|
const std::function<void(Request*)> callback_;
|
2019-05-04 23:00:53 -07:00
|
|
|
const int threads_;
|
|
|
|
|
const std::unordered_set<std::string_view> headers_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // firecgi
|