adding ipv6 support because i like ipv6

This commit is contained in:
ari melody 2026-04-29 01:19:07 +01:00
parent a7c52fd177
commit 223cc8b60b
Signed by: ari
GPG key ID: 60B5F0386E3DDB7E
2 changed files with 53 additions and 1 deletions

14
main.go
View file

@ -24,6 +24,7 @@ import (
"arimelody-web/log"
"arimelody-web/model"
"arimelody-web/view"
amnet "arimelody-web/net"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
@ -518,7 +519,18 @@ func main() {
// start the web server!
mux := createServeMux(&app)
fmt.Printf("Now serving at http://%s:%d\n", app.Config.Host, app.Config.Port)
server := &amnet.DualStackHTTPServer{ Handler: mux }
if err := server.ListenAndServe(app.Config.Host, "::", int(app.Config.Port)); err != nil {
panic(err)
}
fmt.Printf(
"Now listening on port %d (http://%s:%d, http://[%s]:%d)\n",
app.Config.Port,
app.Config.Host,
app.Config.Port,
"::",
app.Config.Port,
)
stdLog.Fatal(
http.ListenAndServe(fmt.Sprintf("%s:%d", app.Config.Host, app.Config.Port),
CheckRequest(&app, HTTPLog(DefaultHeaders(mux))),