#pragma once #include #include #include #include "absl/types/optional.h" #include "envoy_error.h" #include "library/common/types/c_types.h" #include "response_headers.h" #include "response_trailers.h" namespace Envoy { namespace Platform { using OnHeadersCallback = std::function; using OnDataCallback = std::function; using OnTrailersCallback = std::function; using OnErrorCallback = std::function; using OnCompleteCallback = std::function; using OnCancelCallback = std::function; struct StreamCallbacks { absl::optional on_headers; absl::optional on_data; absl::optional on_trailers; absl::optional on_error; absl::optional on_complete; absl::optional on_cancel; }; using StreamCallbacksSharedPtr = std::shared_ptr; class EnvoyHttpCallbacksAdapter { public: EnvoyHttpCallbacksAdapter(StreamCallbacksSharedPtr callbacks); envoy_http_callbacks as_envoy_http_callbacks(); private: static void* c_on_headers(envoy_headers headers, bool end_stream, void* context); static void* c_on_data(envoy_data data, bool end_stream, void* context); static void* c_on_trailers(envoy_headers metadata, void* context); static void* c_on_error(envoy_error raw_error, void* context); static void* c_on_complete(void* context); static void* c_on_cancel(void* context); StreamCallbacksSharedPtr stream_callbacks_; }; using EnvoyHttpCallbacksAdapterSharedPtr = std::shared_ptr; } // namespace Platform } // namespace Envoy