Deleted
Added
nxt_controller.c (112:6f1809436b10) | nxt_controller.c (116:b36238461b48) |
---|---|
1 2/* 3 * Copyright (C) Igor Sysoev 4 * Copyright (C) Valentin V. Bartenev 5 * Copyright (C) NGINX, Inc. 6 */ 7 8#include <nxt_main.h> --- 74 unchanged lines hidden (view full) --- 83nxt_int_t 84nxt_controller_start(nxt_task_t *task, nxt_runtime_t *rt) 85{ 86 nxt_mp_t *mp; 87 nxt_conf_value_t *conf; 88 nxt_http_fields_hash_t *hash; 89 90 static const nxt_str_t json | 1 2/* 3 * Copyright (C) Igor Sysoev 4 * Copyright (C) Valentin V. Bartenev 5 * Copyright (C) NGINX, Inc. 6 */ 7 8#include <nxt_main.h> --- 74 unchanged lines hidden (view full) --- 83nxt_int_t 84nxt_controller_start(nxt_task_t *task, nxt_runtime_t *rt) 85{ 86 nxt_mp_t *mp; 87 nxt_conf_value_t *conf; 88 nxt_http_fields_hash_t *hash; 89 90 static const nxt_str_t json |
91 = nxt_string("{ \"sockets\": {}, \"applications\": {} }"); | 91 = nxt_string("{ \"listeners\": {}, \"applications\": {} }"); |
92 93 hash = nxt_http_fields_hash_create(nxt_controller_request_fields, 94 rt->mem_pool); 95 if (nxt_slow_path(hash == NULL)) { 96 return NXT_ERROR; 97 } 98 99 nxt_controller_fields_hash = hash; --- 488 unchanged lines hidden (view full) --- 588 589 mbuf = &c->read->mem; 590 591 value = nxt_conf_json_parse(mp, mbuf->pos, mbuf->free); 592 593 if (value == NULL) { 594 nxt_mp_destroy(mp); 595 status = 400; | 92 93 hash = nxt_http_fields_hash_create(nxt_controller_request_fields, 94 rt->mem_pool); 95 if (nxt_slow_path(hash == NULL)) { 96 return NXT_ERROR; 97 } 98 99 nxt_controller_fields_hash = hash; --- 488 unchanged lines hidden (view full) --- 588 589 mbuf = &c->read->mem; 590 591 value = nxt_conf_json_parse(mp, mbuf->pos, mbuf->free); 592 593 if (value == NULL) { 594 nxt_mp_destroy(mp); 595 status = 400; |
596 nxt_str_set(&resp.json, "{ \"error\": \"Invalid JSON.\" }"); |
|
596 goto done; 597 } 598 599 if (path.length != 1) { 600 rc = nxt_conf_op_compile(c->mem_pool, &ops, 601 nxt_controller_conf.root, 602 &path, value); 603 --- 11 unchanged lines hidden (view full) --- 615 616 if (nxt_slow_path(value == NULL)) { 617 nxt_mp_destroy(mp); 618 status = 500; 619 goto done; 620 } 621 } 622 | 597 goto done; 598 } 599 600 if (path.length != 1) { 601 rc = nxt_conf_op_compile(c->mem_pool, &ops, 602 nxt_controller_conf.root, 603 &path, value); 604 --- 11 unchanged lines hidden (view full) --- 616 617 if (nxt_slow_path(value == NULL)) { 618 nxt_mp_destroy(mp); 619 status = 500; 620 goto done; 621 } 622 } 623 |
624 if (nxt_slow_path(nxt_conf_validate(value) != NXT_OK)) { 625 status = 400; 626 nxt_str_set(&resp.json, 627 "{ \"error\": \"Invalid configuration.\" }"); 628 goto done; 629 } 630 |
|
623 nxt_mp_destroy(nxt_controller_conf.pool); 624 625 nxt_controller_conf.root = value; 626 nxt_controller_conf.pool = mp; 627 628 nxt_str_set(&resp.json, "{ \"success\": \"Updated.\" }"); 629 630 status = 200; --- 38 unchanged lines hidden (view full) --- 669 } 670 671 if (nxt_slow_path(value == NULL)) { 672 nxt_mp_destroy(mp); 673 status = 500; 674 goto done; 675 } 676 | 631 nxt_mp_destroy(nxt_controller_conf.pool); 632 633 nxt_controller_conf.root = value; 634 nxt_controller_conf.pool = mp; 635 636 nxt_str_set(&resp.json, "{ \"success\": \"Updated.\" }"); 637 638 status = 200; --- 38 unchanged lines hidden (view full) --- 677 } 678 679 if (nxt_slow_path(value == NULL)) { 680 nxt_mp_destroy(mp); 681 status = 500; 682 goto done; 683 } 684 |
685 if (nxt_slow_path(nxt_conf_validate(value) != NXT_OK)) { 686 status = 400; 687 nxt_str_set(&resp.json, 688 "{ \"error\": \"Invalid configuration.\" }"); 689 goto done; 690 } 691 |
|
677 nxt_mp_destroy(nxt_controller_conf.pool); 678 679 nxt_controller_conf.root = value; 680 nxt_controller_conf.pool = mp; 681 682 nxt_str_set(&resp.json, "{ \"success\": \"Deleted.\" }"); 683 684 status = 200; --- 7 unchanged lines hidden (view full) --- 692 switch (status) { 693 694 case 200: 695 nxt_str_set(&resp.status_line, "200 OK"); 696 break; 697 698 case 400: 699 nxt_str_set(&resp.status_line, "400 Bad Request"); | 692 nxt_mp_destroy(nxt_controller_conf.pool); 693 694 nxt_controller_conf.root = value; 695 nxt_controller_conf.pool = mp; 696 697 nxt_str_set(&resp.json, "{ \"success\": \"Deleted.\" }"); 698 699 status = 200; --- 7 unchanged lines hidden (view full) --- 707 switch (status) { 708 709 case 200: 710 nxt_str_set(&resp.status_line, "200 OK"); 711 break; 712 713 case 400: 714 nxt_str_set(&resp.status_line, "400 Bad Request"); |
700 nxt_str_set(&resp.json, "{ \"error\": \"Invalid JSON.\" }"); | |
701 break; 702 703 case 404: 704 nxt_str_set(&resp.status_line, "404 Not Found"); 705 nxt_str_set(&resp.json, "{ \"error\": \"Value doesn't exist.\" }"); 706 break; 707 708 case 405: --- 88 unchanged lines hidden --- | 715 break; 716 717 case 404: 718 nxt_str_set(&resp.status_line, "404 Not Found"); 719 nxt_str_set(&resp.json, "{ \"error\": \"Value doesn't exist.\" }"); 720 break; 721 722 case 405: --- 88 unchanged lines hidden --- |