9#include <google/protobuf/message.h>
11#include <userver/components/component_base.hpp>
12#include <userver/utils/function_ref.hpp>
14#include <userver/ugrpc/server/call.hpp>
15#include <userver/ugrpc/server/middlewares/fwd.hpp>
17USERVER_NAMESPACE_BEGIN
22class MiddlewareCallContext
final {
25 MiddlewareCallContext(
26 const Middlewares& middlewares,
28 utils::function_ref<
void()> user_call,
29 const dynamic_config::Snapshot& config,
30 ::google::protobuf::Message* request
45 void ClearMiddlewaresResources();
47 Middlewares::const_iterator middleware_;
48 Middlewares::const_iterator middleware_end_;
49 utils::function_ref<
void()> user_call_;
53 std::optional<dynamic_config::Snapshot> config_;
54 ::google::protobuf::Message* request_;
55 bool is_called_from_handle_{
false};
68 virtual ~MiddlewareBase();
73 virtual void Handle(MiddlewareCallContext& context)
const = 0;
76 virtual void CallRequestHook(
const MiddlewareCallContext& context, google::protobuf::Message& request);
79 virtual void CallResponseHook(
const MiddlewareCallContext& context, google::protobuf::Message& response);