Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
esquerbatua committed Aug 29, 2024
1 parent 81f9226 commit e98108c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions vlib/vweb/vweb.v
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ fn new_request_app[T](global_app &T, ctx Context, tid int) &T {
return request_app
}

@[manualfree]
fn handle_conn[T](mut conn net.TcpConn, global_app &T, controllers []&ControllerPath, routes &map[string]Route, tid int) {
conn.set_read_timeout(30 * time.second)
conn.set_write_timeout(30 * time.second)
Expand Down Expand Up @@ -756,15 +757,16 @@ fn handle_conn[T](mut conn net.TcpConn, global_app &T, controllers []&Controller
handle_route(mut request_app, url, host, routes, tid)
}

@[manualfree]
fn handle_route[T](mut app T, url urllib.URL, host string, routes &map[string]Route, tid int) {
url_words := url.path.split('/').filter(it != '')
defer {
unsafe {
free(app)
free(url_words)
}
}

url_words := url.path.split('/').filter(it != '')

// Calling middleware...
app.before_request()

Expand Down Expand Up @@ -831,6 +833,9 @@ fn handle_route[T](mut app T, url urllib.URL, host string, routes &map[string]Ro
{
app.$method(args)
}
unsafe {
args.free()
}
} else {
if route.middleware == '' {
app.$method()
Expand Down Expand Up @@ -873,9 +878,15 @@ fn handle_route[T](mut app T, url urllib.URL, host string, routes &map[string]Ro
} else if validate_app_middleware(mut app, route.middleware, method.name) {
app.$method(method_args)
}
unsafe {
method_args.free()
}
return
}
}
unsafe {
route_words.free()
}
}
}
}
Expand Down

0 comments on commit e98108c

Please sign in to comment.