noidb/src/database.hh
2024-05-01 16:41:23 -04:00

62 lines
1.5 KiB
C++

#pragma once
#include <seastar/http/httpd.hh>
using namespace seastar;
using namespace httpd;
#include <string>
class Database {
public:
explicit Database() = default;
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);
};
class GetHandler : public handler_base {
public:
explicit GetHandler(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;
private:
Database& db;
};
class PutHandler : public handler_base {
public:
explicit PutHandler(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;
private:
Database& db;
};
class PostHandler : public handler_base {
public:
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;
private:
Database& db;
};
class DeleteHandler : public handler_base {
public:
explicit DeleteHandler(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;
private:
Database& db;
};