mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: fix request checking (#6027)
This commit is contained in:
parent
91c9c0c917
commit
1fd499ed4a
@ -378,28 +378,28 @@ fn handle_conn<T>(conn net.Socket, mut app T) {
|
|||||||
} else {
|
} else {
|
||||||
// Get methods
|
// Get methods
|
||||||
// Get is default
|
// 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('/'))
|
route_words_a = attrs.filter(it.to_lower() != 'post').map(it[1..].split('/'))
|
||||||
}
|
}
|
||||||
} else if 'put' in attrs {
|
} else if req.method == .put {
|
||||||
if req.method == .put {
|
if 'put' in attrs {
|
||||||
route_words_a = attrs.filter(it.to_lower() != 'put').map(it[1..].split('/'))
|
route_words_a = attrs.filter(it.to_lower() != 'put').map(it[1..].split('/'))
|
||||||
}
|
}
|
||||||
} else if 'patch' in attrs {
|
} else if req.method == .patch {
|
||||||
if req.method == .patch {
|
if 'patch' in attrs {
|
||||||
route_words_a = attrs.filter(it.to_lower() != 'patch').map(it[1..].split('/'))
|
route_words_a = attrs.filter(it.to_lower() != 'patch').map(it[1..].split('/'))
|
||||||
}
|
}
|
||||||
} else if 'delete' in attrs {
|
} else if req.method == .delete {
|
||||||
if req.method == .delete {
|
if 'delete' in attrs {
|
||||||
route_words_a = attrs.filter(it.to_lower() != 'delete').map(it[1..].split('/'))
|
route_words_a = attrs.filter(it.to_lower() != 'delete').map(it[1..].split('/'))
|
||||||
}
|
}
|
||||||
} else if 'head' in attrs {
|
} else if req.method == .head {
|
||||||
if req.method == .head {
|
if 'head' in attrs {
|
||||||
route_words_a = attrs.filter(it.to_lower() != 'head').map(it[1..].split('/'))
|
route_words_a = attrs.filter(it.to_lower() != 'head').map(it[1..].split('/'))
|
||||||
}
|
}
|
||||||
} else if 'options' in attrs {
|
} else if req.method == .options {
|
||||||
if req.method == .options {
|
if 'options' in attrs {
|
||||||
route_words_a = attrs.filter(it.to_lower() != 'options').map(it[1..].split('/'))
|
route_words_a = attrs.filter(it.to_lower() != 'options').map(it[1..].split('/'))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -460,11 +460,6 @@ fn handle_conn<T>(conn net.Socket, mut app T) {
|
|||||||
conn.send_string(http_404) or {}
|
conn.send_string(http_404) or {}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
send_action<T>(action, vars, mut app)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn send_action<T>(action string, vars []string, mut app T) {
|
|
||||||
// TODO remove this function
|
|
||||||
$for method in T.methods {
|
$for method in T.methods {
|
||||||
$if method.@type is Result {
|
$if method.@type is Result {
|
||||||
// search again for method
|
// search again for method
|
||||||
|
Loading…
Reference in New Issue
Block a user