From 1fd499ed4a8c2a092a6ef0a413daf0ace7d523ea Mon Sep 17 00:00:00 2001 From: Louis Schmieder Date: Fri, 31 Jul 2020 01:26:56 +0200 Subject: [PATCH] vweb: fix request checking (#6027) --- vlib/vweb/vweb.v | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 497b1d1fb1..9298d4fbe0 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -378,28 +378,28 @@ fn handle_conn(conn net.Socket, mut app T) { } else { // Get methods // Get is default - if 'post' in attrs { - if req.method == .post { + if req.method == .post { + if 'post' in attrs { route_words_a = attrs.filter(it.to_lower() != 'post').map(it[1..].split('/')) } - } else if 'put' in attrs { - if req.method == .put { + } else if req.method == .put { + if 'put' in attrs { route_words_a = attrs.filter(it.to_lower() != 'put').map(it[1..].split('/')) } - } else if 'patch' in attrs { - if req.method == .patch { + } else if req.method == .patch { + if 'patch' in attrs { route_words_a = attrs.filter(it.to_lower() != 'patch').map(it[1..].split('/')) } - } else if 'delete' in attrs { - if req.method == .delete { + } else if req.method == .delete { + if 'delete' in attrs { route_words_a = attrs.filter(it.to_lower() != 'delete').map(it[1..].split('/')) } - } else if 'head' in attrs { - if req.method == .head { + } else if req.method == .head { + if 'head' in attrs { route_words_a = attrs.filter(it.to_lower() != 'head').map(it[1..].split('/')) } - } else if 'options' in attrs { - if req.method == .options { + } else if req.method == .options { + if 'options' in attrs { route_words_a = attrs.filter(it.to_lower() != 'options').map(it[1..].split('/')) } } else { @@ -460,11 +460,6 @@ fn handle_conn(conn net.Socket, mut app T) { conn.send_string(http_404) or {} return } - send_action(action, vars, mut app) -} - -fn send_action(action string, vars []string, mut app T) { - // TODO remove this function $for method in T.methods { $if method.@type is Result { // search again for method