Files
firecgi/server.h

33 lines
691 B
C
Raw Normal View History

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:
Server(int port, const std::function<void(Request*)>& callback, int threads=1, const std::unordered_set<std::string_view>& headers={}, int max_request_len=(16*1024));
2019-05-04 23:00:53 -07:00
void Serve();
void Shutdown();
void RegisterSignalHandlers();
2019-05-04 23:00:53 -07:00
private:
Connection *NewConn(int listen_sock, int epoll_fd);
2019-05-04 23:00:53 -07:00
int NewListenSock();
void ServeInt();
const int port_;
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_;
const int max_request_len_;
int close_fd_;
2019-05-04 23:00:53 -07:00
};
} // firecgi