@@ -15,15 +15,15 @@ import (
15
15
16
16
// Constants defining default configuration values and environment variable names.
17
17
const (
18
- defaultPort = ": 8080" // defaultPort is the default server port if PORT is unset.
18
+ defaultPort = "8080" // defaultPort is the default server port if PORT is unset.
19
19
trustedProxiesEnv = "TRUSTED_PROXIES" // trustedProxiesEnv is the environment variable for trusted proxy IPs.
20
20
staticDirEnv = "STATIC_DIR" // staticDirEnv is the environment variable for the static directory.
21
21
defaultStaticDir = "static" // defaultStaticDir is the default static directory relative to the project root.
22
22
)
23
23
24
24
// Config holds server configuration parameters.
25
25
type Config struct {
26
- Port string // Port is the server listening port (e.g., ": 8080").
26
+ Port string // Port is the server listening port (e.g., "8080").
27
27
TrustedProxies []string // TrustedProxies lists IP addresses of trusted reverse proxies.
28
28
StaticDir string // StaticDir is the directory containing static files.
29
29
}
@@ -32,7 +32,7 @@ type Config struct {
32
32
// It defaults to port ":8080" if PORT is unset and processes TRUSTED_PROXIES as a comma-separated list,
33
33
// trimming whitespace, logging warnings for empty entries, and filtering them out. Returns the configuration and any error encountered.
34
34
func LoadConfig () (Config , error ) {
35
- config := Config {Port : defaultPort , StaticDir : defaultStaticDir }
35
+ config := Config {Port : ":" + defaultPort , StaticDir : defaultStaticDir }
36
36
if port := os .Getenv ("PORT" ); port != "" {
37
37
config .Port = ":" + port
38
38
}
0 commit comments