Skip to content

Commit ac984c0

Browse files
committed
feat:修改环境变量的赋值方式
1 parent 5f9bc1a commit ac984c0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

source/nginx_polaris_limit_module/ngx_http_polaris_limit_module.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,27 +212,27 @@ static char *ngx_http_polaris_limit_conf_set(ngx_conf_t *cf, ngx_command_t *cmd,
212212
}
213213

214214
if (!has_namespace) {
215-
char *namespace_env_value = getenv(ENV_NAMESPACE.c_str());
215+
const char *namespace_env_value = getenv(ENV_NAMESPACE.c_str());
216216
if (NULL != namespace_env_value) {
217-
plcf->service_namespace = std::string(namespace_env_value);
217+
plcf->service_namespace.assign(namespace_env_value);
218218
} else {
219219
plcf->service_namespace = DEFAULT_NAMESPACE;
220220
}
221221
ngx_conf_log_error(NGX_LOG_NOTICE, cf, 0, "[PolarisRateLimiting] use %s as nginx namespace", plcf->service_namespace.c_str());
222222
}
223223

224224
if (!has_service) {
225-
char *service_env_value = getenv(ENV_SERVICE.c_str());
225+
const char *service_env_value = getenv(ENV_SERVICE.c_str());
226226
if (NULL != service_env_value) {
227-
plcf->service_name = std::string(service_env_value);
227+
plcf->service_name.assign(service_env_value);
228228
} else {
229229
plcf->service_name = DEFAULT_SERVICE;
230230
}
231231
ngx_conf_log_error(NGX_LOG_NOTICE, cf, 0, "[PolarisRateLimiting] use %s as nginx service name", plcf->service_name.c_str());
232232
}
233233

234234
if (!has_enable) {
235-
char *enable_env_value = getenv(ENV_RATELIMIT_ENABLE.c_str());
235+
const char *enable_env_value = getenv(ENV_RATELIMIT_ENABLE.c_str());
236236
if (NULL != enable_env_value) {
237237
std::string enable_str = std::string(enable_env_value);
238238
plcf->enable = string2bool(enable_str) ? 1 : 0;

0 commit comments

Comments
 (0)