noidb/src/database.hh

63 lines
1.5 KiB
C++
Raw Normal View History

2024-05-01 19:59:30 +00:00
#pragma once
#include <seastar/http/httpd.hh>
using namespace seastar;
using namespace httpd;
#include <string>
class Database {
public:
2024-05-01 20:41:23 +00:00
explicit Database() = default;
2024-05-01 19:59:30 +00:00
2024-05-01 20:41:23 +00:00
future<bool> stop();
future<sstring> get(const sstring& key);
future<bool> put(const sstring& key, sstring& val);
future<bool> post(const sstring& key, input_stream<char>* val);
future<bool> del(const sstring& key);
2024-05-01 19:59:30 +00:00
};
class GetHandler : public handler_base {
public:
explicit GetHandler(Database& db);
2024-05-01 20:41:23 +00:00
future<std::unique_ptr<http::reply>>
handle(const sstring& path, std::unique_ptr<http::request> req, std::unique_ptr<http::reply> rep) override;
2024-05-01 19:59:30 +00:00
private:
Database& db;
};
class PutHandler : public handler_base {
public:
explicit PutHandler(Database& db);
2024-05-01 20:41:23 +00:00
future<std::unique_ptr<http::reply>>
handle(const sstring& path, std::unique_ptr<http::request> req, std::unique_ptr<http::reply> rep) override;
2024-05-01 19:59:30 +00:00
private:
Database& db;
};
2024-05-01 20:41:23 +00:00
class PostHandler : public handler_base {
2024-05-01 19:59:30 +00:00
public:
2024-05-01 20:41:23 +00:00
explicit PostHandler(Database& db);
future<std::unique_ptr<http::reply>>
handle(const sstring& path, std::unique_ptr<http::request> req, std::unique_ptr<http::reply> rep) override;
2024-05-01 19:59:30 +00:00
2024-05-01 20:41:23 +00:00
private:
Database& db;
};
class DeleteHandler : public handler_base {
public:
2024-05-01 19:59:30 +00:00
explicit DeleteHandler(Database& db);
2024-05-01 20:41:23 +00:00
future<std::unique_ptr<http::reply>>
handle(const sstring& path, std::unique_ptr<http::request> req, std::unique_ptr<http::reply> rep) override;
2024-05-01 19:59:30 +00:00
private:
Database& db;
};