Skip to content

Commit

Permalink
parsing json key-value check key-format if meeting : format and updat…
Browse files Browse the repository at this point in the history
…e readme
  • Loading branch information
xiaokai-wang committed Dec 7, 2015
1 parent b681c1c commit 0910e73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ http_interface example:
```
curl -X PUT -d "{\"weight\":1, \"max_fails\":2, \"fail_timeout\":10}" http://$consul_ip:$port/v1/kv/$dir1/$upstream_name/$backend_ip:$backend_port
or
curl -X PUT -d '{"weight":1, "max_fails":2, "fail_timeout":10}" http://$consul_ip:$port/v1/kv/$dir1/$upstream_name/$backend_ip:$backend_port
curl -X PUT -d '{"weight":1, "max_fails":2, "fail_timeout":10}' http://$consul_ip:$port/v1/kv/$dir1/$upstream_name/$backend_ip:$backend_port
```
value support json format.

Expand Down
8 changes: 6 additions & 2 deletions src/ngx_http_dynamic_update_upstream_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,7 @@ static ngx_int_t
ngx_http_dynamic_update_upstream_parse_json(u_char *buf,
ngx_http_dynamic_update_upstream_server_t *conf_server)
{
u_char *p;
u_char *p, *port_p;
ngx_int_t max_fails=2, backup=0, down=0;
ngx_str_t src, dst;
ngx_http_update_conf_t *upstream_conf=NULL;
Expand Down Expand Up @@ -1486,6 +1486,10 @@ ngx_http_dynamic_update_upstream_parse_json(u_char *buf,
cJSON *temp1 = cJSON_GetObjectItem(server_next, "Key");
if (temp1 != NULL && temp1->valuestring != NULL) {
p = (u_char *)ngx_strrchr(temp1->valuestring, '/');
port_p = (u_char *)ngx_strchr(p, ':');
if (port_p == NULL) {
continue;
}

upstream_conf = ngx_array_push(&ctx->upstream_conf);
ngx_memzero(upstream_conf, sizeof(*upstream_conf));
Expand Down Expand Up @@ -1953,7 +1957,7 @@ ngx_http_dynamic_update_upstream_init_process(ngx_cycle_t *cycle)
ngx_destroy_pool(pool);
ctx->pool = NULL;

break;
continue;
}

return NGX_ERROR;
Expand Down

0 comments on commit 0910e73

Please sign in to comment.