2019-04-28 00:17:32 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-04-28 06:47:30 +00:00
|
|
|
#include <functional>
|
|
|
|
|
#include <memory>
|
2019-04-30 02:07:48 +00:00
|
|
|
#include <unordered_set>
|
2019-04-28 06:47:30 +00:00
|
|
|
|
|
|
|
|
#include "fastcgi_request.h"
|
|
|
|
|
|
2019-04-28 00:17:32 +00:00
|
|
|
class FastCGIServer {
|
|
|
|
|
public:
|
2019-04-30 02:07:48 +00:00
|
|
|
FastCGIServer(int port, const std::function<void(std::unique_ptr<FastCGIRequest>)>& callback, const std::unordered_set<std::string_view>& headers={});
|
2019-04-28 00:17:32 +00:00
|
|
|
void Serve();
|
|
|
|
|
|
|
|
|
|
private:
|
2019-05-04 07:21:52 +00:00
|
|
|
void NewConn();
|
|
|
|
|
|
2019-04-30 02:07:48 +00:00
|
|
|
const std::function<void(std::unique_ptr<FastCGIRequest>)> callback_;
|
|
|
|
|
const std::unordered_set<std::string_view> headers_;
|
2019-05-04 07:21:52 +00:00
|
|
|
int epoll_fd_;
|
|
|
|
|
int listen_sock_;
|
2019-04-28 00:17:32 +00:00
|
|
|
};
|