mirror of
https://github.com/vlang/v.git
synced 2025-09-14 15:02:33 +03:00
net.http: support passing on_running, on_stopped, on_closed callback functions to http.Server{}, as well as show_startup_message: false. (#19591)
This commit is contained in:
parent
69d62e458b
commit
0a89f3082d
3 changed files with 172 additions and 27 deletions
|
@ -22,7 +22,17 @@ mut:
|
|||
is_blocking bool
|
||||
}
|
||||
|
||||
pub fn dial_tcp(address string) !&TcpConn {
|
||||
pub fn dial_tcp(oaddress string) !&TcpConn {
|
||||
mut address := oaddress
|
||||
$if windows {
|
||||
// resolving 0.0.0.0 to localhost, works on linux and macos, but not on windows, so try to emulate it:
|
||||
if address.starts_with(':::') {
|
||||
address = address.replace_once(':::', 'localhost:')
|
||||
}
|
||||
if address.starts_with('0.0.0.0:') {
|
||||
address = address.replace_once('0.0.0.0:', 'localhost:')
|
||||
}
|
||||
}
|
||||
addrs := resolve_addrs_fuzzy(address, .tcp) or {
|
||||
return error('${err.msg()}; could not resolve address ${address} in dial_tcp')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue