Skip to content

Commit

Permalink
Move content_type route config into headers (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
junr03 authored Oct 12, 2016
1 parent 6b4ac35 commit 1148eb9
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
4 changes: 3 additions & 1 deletion configs/envoy_service_to_service.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
{
"timeout_ms": 0,
"prefix": "/",
"content_type": "application/grpc",
"headers": [
{"name": "content-type", "value": "application/grpc"}
],
"cluster": "local_service_grpc"
},
{
Expand Down
5 changes: 0 additions & 5 deletions docs/configuration/http_conn_man/route_config/route.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ next (e.g., redirect, forward, rewrite, etc.).
"host_rewrite": "...",
"case_sensitive": "...",
"timeout_ms": "...",
"content_type": "...",
"runtime": "{...}",
"retry_policy": "{...}",
"rate_limit": "{...}",
Expand Down Expand Up @@ -75,10 +74,6 @@ timeout_ms
:ref:`config_http_filters_router_x-envoy-upstream-rq-per-try-timeout-ms`, and the
:ref:`retry overview <arch_overview_http_routing_retry>`.

content_type
*(optional, string)* Indicates that the route should additionally match on the *content-type*
HTTP header.

:ref:`runtime <config_http_conn_man_route_table_route_runtime>`
*(optional, object)* Indicates that the route should additionally match on a runtime key.

Expand Down
4 changes: 3 additions & 1 deletion examples/grpc-bridge/config/s2s-grpc-envoy.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
{
"timeout_ms": 0,
"prefix": "/",
"content_type": "application/grpc",
"headers": [
{"name": "content-type", "value": "application/grpc"}
],
"cluster": "local_service_grpc"
}
]
Expand Down
8 changes: 2 additions & 6 deletions source/common/router/config_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ RouteEntryImplBase::RouteEntryImplBase(const VirtualHost& vhost, const Json::Obj
runtime_(loadRuntimeData(route)), loader_(loader),
host_redirect_(route.getString("host_redirect", "")),
path_redirect_(route.getString("path_redirect", "")), retry_policy_(route),
content_type_(route.getString("content_type", "")), rate_limit_policy_(route),
shadow_policy_(route), priority_(ConfigUtility::parsePriority(route)) {
rate_limit_policy_(route), shadow_policy_(route),
priority_(ConfigUtility::parsePriority(route)) {

// Check to make sure that we are either a redirect route or we have a cluster.
if (!(isRedirect() ^ !cluster_name_.empty())) {
Expand All @@ -84,10 +84,6 @@ bool RouteEntryImplBase::matches(const Http::HeaderMap& headers, uint64_t random
random_value);
}

if (!content_type_.empty()) {
matches &= (headers.get(Http::Headers::get().ContentType) == content_type_);
}

if (!config_headers_.empty()) {
for (const HeaderData& header_data : config_headers_) {
if (header_data.value_ == EMPTY_STRING) {
Expand Down
1 change: 0 additions & 1 deletion source/common/router/config_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ class RouteEntryImplBase : public RouteEntry, public Matchable, public RedirectE
const std::string host_redirect_;
const std::string path_redirect_;
const RetryPolicyImpl retry_policy_;
const std::string content_type_;
const RateLimitPolicyImpl rate_limit_policy_;
const ShadowPolicyImpl shadow_policy_;
const Upstream::ResourcePriority priority_;
Expand Down
4 changes: 3 additions & 1 deletion test/common/router/config_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ TEST(RouteMatcherTest, ContentType) {
{
"prefix": "/",
"cluster": "local_service_grpc",
"content_type": "application/grpc"
"headers" : [
{"name": "content-type", "value": "application/grpc"}
]
},
{
"prefix": "/",
Expand Down

0 comments on commit 1148eb9

Please sign in to comment.