mirror of
https://github.com/tarampampam/error-pages.git
synced 2024-08-30 18:22:40 +00:00
36c5472987
* 🐛 fix(server.go): validate IP address before starting server ✨ feat(server.go): add support for IPv6 addresses * ✨ feat(cli): add support for IPv6 addresses in the `--listen` flag * 🐛 fix(server.go): add nolint comment to ignore magic number warning in ipv6 check * 🐛 fix(server.go): use fmt.Sprintf to format IP and port instead of strconv.Itoa and string concatenation
32 lines
780 B
Go
32 lines
780 B
Go
package shared
|
|
|
|
import (
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"gh.tarampamp.am/error-pages/internal/env"
|
|
)
|
|
|
|
var ConfigFileFlag = &cli.StringFlag{ //nolint:gochecknoglobals
|
|
Name: "config-file",
|
|
Aliases: []string{"c"},
|
|
Usage: "path to the config file (yaml)",
|
|
Value: "./error-pages.yml",
|
|
EnvVars: []string{env.ConfigFilePath.String()},
|
|
}
|
|
|
|
var ListenAddrFlag = &cli.StringFlag{ //nolint:gochecknoglobals
|
|
Name: "listen",
|
|
Aliases: []string{"l"},
|
|
Usage: "IP (v4 or v6) address to Listen on",
|
|
Value: "0.0.0.0",
|
|
EnvVars: []string{env.ListenAddr.String()},
|
|
}
|
|
|
|
var ListenPortFlag = &cli.UintFlag{ //nolint:gochecknoglobals
|
|
Name: "port",
|
|
Aliases: []string{"p"},
|
|
Usage: "TCP port number",
|
|
Value: 8080, //nolint:gomnd
|
|
EnvVars: []string{env.ListenPort.String()},
|
|
}
|