parse env variable in dedicated struct
This commit is contained in:
+3
-3
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user