[master] dd2c75542 polish backend.list -pj output
Nils Goroll
nils.goroll at uplex.de
Wed Mar 6 17:26:07 UTC 2019
commit dd2c755424a15d05f6b4742070b7004bee14fbaa
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Wed Mar 6 18:09:53 2019 +0100
polish backend.list -pj output
interface-meister @slimhazard tells me the JSONista want objects
Ref #2896
diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c
index 50df8c799..0ed228524 100644
--- a/lib/libvmod_directors/fall_back.c
+++ b/lib/libvmod_directors/fall_back.c
@@ -97,10 +97,21 @@ vmod_fallback_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag,
if (jflag) {
if (u)
VSB_cat(vsb, ",\n");
- VSB_printf(vsb, "\"%s\": [%s, \"%s\"]",
- be->vcl_name,
- fb->cur == u ? "true" : "false",
- h ? "healthy" : "sick");
+ VSB_printf(vsb, "\"%s\": {\n", be->vcl_name);
+ VSB_indent(vsb, 2);
+
+ if (fb->cur == u)
+ VSB_cat(vsb, "\"current\": true,\n");
+ else
+ VSB_cat(vsb, "\"current\": false,\n");
+
+ if (h)
+ VSB_cat(vsb, "\"health\": \"healthy\"\n");
+ else
+ VSB_cat(vsb, "\"health\": \"sick\"\n");
+
+ VSB_indent(vsb, -2);
+ VSB_cat(vsb, "}");
} else {
VSB_cat(vsb, "\t");
VSB_cat(vsb, be->vcl_name);
diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c
index d40611c97..027611296 100644
--- a/lib/libvmod_directors/vdir.c
+++ b/lib/libvmod_directors/vdir.c
@@ -234,13 +234,19 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag,
if (jflag) {
if (u)
VSB_cat(vsb, ",\n");
+ VSB_printf(vsb, "\"%s\": {\n", be->vcl_name);
+ VSB_indent(vsb, 2);
+
if (weight)
- VSB_printf(vsb, "\"%s\": [%f, \"%s\"]",
- be->vcl_name, w,
- h ? "healthy" : "sick");
+ VSB_printf(vsb, "\"weight\": %f,\n", w);
+
+ if (h)
+ VSB_cat(vsb, "\"health\": \"healthy\"\n");
else
- VSB_printf(vsb, "\"%s\": \"%s\"",
- be->vcl_name, h ? "healthy" : "sick");
+ VSB_cat(vsb, "\"health\": \"sick\"\n");
+
+ VSB_indent(vsb, -2);
+ VSB_cat(vsb, "}");
} else {
VSB_cat(vsb, "\t");
VSB_cat(vsb, be->vcl_name);
More information about the varnish-commit
mailing list