all repos — searchix @ 6fed92fd9acc567e6a1ebd939402b9198da40b86

Search engine for NixOS, nix-darwin, home-manager and NUR users

style: make port a string for easier nix integration
Alan Pearce alan@alanpearce.eu
Mon, 13 May 2024 23:04:50 +0200
commit

6fed92fd9acc567e6a1ebd939402b9198da40b86

parent

45432ae8006322e89f89f43423ff26c99d98de10

2 files changed, 4 insertions(+), 3 deletions(-)

jump to
M internal/config/config.gointernal/config/config.go
@@ -61,7 +61,7 @@ type Web struct {
 	ContentSecurityPolicy CSP
 	ListenAddress         string
-	Port                  string
+	Port                  int
 	BaseURL               URL
 	SentryDSN             string
 	Environment           string
@@ -86,7 +86,7 @@ var defaultConfig = Config{ 	DataPath: "./data",
 	Web: &Web{
 		ListenAddress: "localhost",
-		Port:          "3000",
+		Port:          3000,
 		BaseURL:       mustURL("http://localhost:3000"),
 		ContentSecurityPolicy: CSP{
 			DefaultSrc: []string{"'self'"},
M internal/server/server.gointernal/server/server.go
@@ -8,6 +8,7 @@ "net" 	"net/http"
 	"searchix/internal/config"
 	"searchix/internal/index"
+	"strconv"
 	"time"
 
 	"github.com/pkg/errors"
@@ -22,7 +23,7 @@ mux, err := NewMux(conf, index, liveReload) 	if err != nil {
 		return nil, err
 	}
-	listenAddress := net.JoinHostPort(conf.Web.ListenAddress, conf.Web.Port)
+	listenAddress := net.JoinHostPort(conf.Web.ListenAddress, strconv.Itoa(conf.Web.Port))
 
 	return &Server{
 		&http.Server{