forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
header: HeaderListView implementation (envoyproxy#10733)
This is an abstraction of HeaderList. This is required for us to return all of headers from HeaderMap to implement List/Map expression processor for google/cel which is not implemented right now. Signed-off-by: shikugawa <rei@tetrate.io>
- Loading branch information
Showing
5 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "common/http/header_list_view.h" | ||
|
||
namespace Envoy { | ||
namespace Http { | ||
|
||
HeaderListView::HeaderListView(const HeaderMap& header_map) { | ||
header_map.iterate( | ||
[](const Http::HeaderEntry& header, void* context) -> HeaderMap::Iterate { | ||
auto* context_ptr = static_cast<HeaderListView*>(context); | ||
context_ptr->keys_.emplace_back(std::reference_wrapper<const HeaderString>(header.key())); | ||
context_ptr->values_.emplace_back( | ||
std::reference_wrapper<const HeaderString>(header.value())); | ||
return HeaderMap::Iterate::Continue; | ||
}, | ||
this); | ||
} | ||
|
||
} // namespace Http | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
|
||
#include "envoy/http/header_map.h" | ||
|
||
namespace Envoy { | ||
namespace Http { | ||
|
||
class HeaderListView { | ||
public: | ||
using HeaderStringRefs = std::vector<std::reference_wrapper<const HeaderString>>; | ||
|
||
HeaderListView(const HeaderMap& header_map); | ||
const HeaderStringRefs& keys() const { return keys_; } | ||
const HeaderStringRefs& values() const { return values_; } | ||
|
||
private: | ||
HeaderStringRefs keys_; | ||
HeaderStringRefs values_; | ||
}; | ||
|
||
} // namespace Http | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters