userver: samples/postgres_auth/postgres_service.cpp
Loading...
Searching...
No Matches
samples/postgres_auth/postgres_service.cpp
#include "auth_bearer.hpp"
#include "user_info_cache.hpp"
namespace samples::pg {
class Hello final : public server::handlers::HttpHandlerBase {
public:
static constexpr std::string_view kName = "handler-hello";
using HttpHandlerBase::HttpHandlerBase;
std::string HandleRequestThrow(
server::request::RequestContext& ctx) const override {
return "Hello world, " + ctx.GetData<std::string>("name") + "!\n";
}
};
} // namespace samples::pg
int main(int argc, const char* const argv[]) {
server::handlers::auth::RegisterAuthCheckerFactory(
"bearer", std::make_unique<samples::pg::CheckerFactory>());
const auto component_list = components::MinimalServerComponentList()
.Append<samples::pg::AuthCache>()
.Append<components::Postgres>("auth-database")
.Append<samples::pg::Hello>()
.Append<components::TestsuiteSupport>()
return utils::DaemonMain(argc, argv, component_list);
}