userver: samples/grpc_middleware_service/src/middlewares/client/middleware.cpp
Loading...
Searching...
No Matches
samples/grpc_middleware_service/src/middlewares/client/middleware.cpp
#include "middleware.hpp"
#include <middlewares/auth.hpp>
namespace sample::grpc::auth::client {
void ApplyCredentials(::grpc::ClientContext& context) {
context.AddMetadata(kKey, kCredentials);
}
Middleware::Middleware() = default;
Middleware::~Middleware() = default;
void Middleware::Handle(ugrpc::client::MiddlewareCallContext& context) const {
ApplyCredentials(context.GetCall().GetContext());
context.Next();
}
MiddlewareFactory::MiddlewareFactory(const components::ComponentContext&) {}
MiddlewareFactory::~MiddlewareFactory() = default;
std::shared_ptr<const Middleware::MiddlewareBase>
MiddlewareFactory::GetMiddleware(std::string_view) const {
return std::make_shared<Middleware>();
}
} // namespace sample::grpc::auth::client