-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathconfiguration.h
56 lines (47 loc) · 1.95 KB
/
configuration.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include <string>
#include "envoy/api/v2/core/base.pb.h"
#include "envoy/config/core/v3/base.pb.h"
#include "envoy/http/header_map.h"
#include "api/server/response_options.pb.h"
namespace Nighthawk {
namespace Server {
namespace Configuration {
/**
* Merges a json string containing configuration into a ResponseOptions instance.
*
* @param json Json-formatted seralization of ResponseOptions to merge into the configuration.
* @param config The target that the json string should be merged into.
* @param error_message Set to an error message if one occurred, else set to an empty string.
* @return bool false if an error occurred.
*/
bool mergeJsonConfig(absl::string_view json, nighthawk::server::ResponseOptions& config,
std::string& error_message);
/**
* Applies ResponseOptions onto a HeaderMap containing response headers.
*
* @param response_headers Response headers to transform to reflect the passed in response
* options.
* @param response_options Configuration specifying how to transform the header map.
*
* @throws Envoy::EnvoyException if invalid response_options are provided.
*/
void applyConfigToResponseHeaders(Envoy::Http::ResponseHeaderMap& response_headers,
const nighthawk::server::ResponseOptions& response_options);
/**
* Upgrades Envoy's HeaderValueOption from the deprecated v2 API version to v3.
*
* @param v2_header_value_option The HeaderValueOption to be upgraded.
* @return a version of HeaderValueOption upgraded to Envoy API v3.
*/
envoy::config::core::v3::HeaderValueOption upgradeDeprecatedEnvoyV2HeaderValueOptionToV3(
const envoy::api::v2::core::HeaderValueOption& v2_header_value_option);
/**
* Validates the ResponseOptions.
*
* @throws Envoy::EnvoyException on validation errors.
*/
void validateResponseOptions(const nighthawk::server::ResponseOptions& response_options);
} // namespace Configuration
} // namespace Server
} // namespace Nighthawk