#include <samples_postgres_service/sql_queries.hpp>
namespace samples_postgres_service::pg {
public:
static constexpr std::string_view kName = "handler-key-value";
private:
std::string DeleteValue(std::string_view key) const;
};
}
namespace samples_postgres_service::pg {
: HttpHandlerBase(config, context),
pg_cluster_(context.FindComponent<
components::Postgres>(
"key-value-database").GetCluster()) {}
const auto& key = request.
GetArg(
"key");
if (key.empty()) {
}
request.
GetHttpResponse().
SetContentType(http::content_type::kTextPlain);
case server::http::HttpMethod::kGet:
return GetValue(key, request);
case server::http::HttpMethod::kPost:
return PostValue(key, request);
case server::http::HttpMethod::kDelete:
return DeleteValue(key);
default:
fmt::format(
"Unsupported method {}", request.
GetMethod())});
}
}
return {};
}
}
const auto& value = request.
GetArg(
"value");
auto res = transaction.
Execute(sql::kInsertValue, key, value);
if (res.
RowsAffected()) {
return std::string{value};
}
res = transaction.Execute(sql::kSelectValue, key);
if (result != value) {
}
}
std::string KeyValue::DeleteValue(std::string_view key) const {
return std::to_string(res.RowsAffected());
}
}
int main(int argc, char* argv[]) {
.
Append<samples_postgres_service::pg::KeyValue>()
.Append<components::Postgres>("key-value-database")
.Append<components::TestsuiteSupport>()
.Append<clients::dns::Component>();
}