mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: refactor routing logic (#9025)
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
module main
|
||||
|
||||
import vweb
|
||||
import rand
|
||||
|
||||
const (
|
||||
port = 8082
|
||||
@ -21,8 +22,10 @@ pub fn (mut app App) init_once() {
|
||||
app.handle_static('.', false)
|
||||
}
|
||||
|
||||
pub fn (mut app App) json_endpoint() vweb.Result {
|
||||
return app.json('{"a": 3}')
|
||||
['/users/:user']
|
||||
pub fn (mut app App) user_endpoint(user string) vweb.Result {
|
||||
id := rand.intn(100)
|
||||
return app.json('{"$user": $id}')
|
||||
}
|
||||
|
||||
pub fn (mut app App) index() vweb.Result {
|
||||
|
Reference in New Issue
Block a user