Deleted Added
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\": {} }");
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 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
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
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");
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 ---