From a6df3e51d2ce40fba073c90e71afab9cd9ce255e Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 30 Jul 2019 05:13:44 +0200 Subject: [PATCH] vweb.json() --- vlib/vweb/vweb.v | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 7ee109a89f..2824aedd91 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -16,8 +16,14 @@ pub: headers []string } -pub fn (ctx Context) write(s string) { - //ctx.conn.write(s) +pub fn (ctx Context) json(s string) { + h := ctx.headers.join('\n') + ctx.conn.write('HTTP/1.1 200 OK +Content-Type: application/json +$h + +$s +') } pub fn (ctx Context) redirect(url string) {