parse env variable in dedicated struct

This commit is contained in:
rmanach
2025-01-03 10:06:54 +01:00
parent 0d48db8b94
commit f712242e39
4 changed files with 69 additions and 36 deletions
+3 -3
View File
@@ -3,6 +3,7 @@ package server
import (
"context"
"errors"
"librapi/services"
"net/http"
"strconv"
"time"
@@ -13,7 +14,6 @@ import (
const (
ServerShutdownTimeout = 10 * time.Second
ServerReadTimeout = 5 * time.Second
DefaultPort = 8888
)
type Handler struct {
@@ -35,8 +35,8 @@ type ServerOption func()
func NewServer(ctx context.Context, port int, handlers ...Handler) Server {
if port == 0 {
log.Warn().Int("port", DefaultPort).Msg("no port detected, set to default")
port = DefaultPort
log.Warn().Int("port", services.GetEnv().GetPort()).Msg("no port detected, set to default")
port = services.GetEnv().GetPort()
}
srvmux := http.NewServeMux()