Skip to content

Commit

Permalink
Fix typo > Prefered > Preferred
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudk committed Feb 23, 2022
1 parent d96ec9f commit 503c5ef
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
16 changes: 8 additions & 8 deletions local/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ type ServerCallback func(w http.ResponseWriter, r *http.Request, env map[string]

// Server represents a server
type Server struct {
DocumentRoot string
Callback ServerCallback
PreferedPort int
PKCS12 string
AllowHTTP bool
Logger zerolog.Logger
Appversion string
DocumentRoot string
Callback ServerCallback
PreferredPort int
PKCS12 string
AllowHTTP bool
Logger zerolog.Logger
Appversion string

httpserver *http.Server
httpsserver *http.Server
Expand All @@ -59,7 +59,7 @@ type Server struct {

// Start starts the server
func (s *Server) Start(errChan chan error) (int, error) {
ln, port, err := process.CreateListener(s.PreferedPort)
ln, port, err := process.CreateListener(s.PreferredPort)
if err != nil {
return port, errors.WithStack(err)
}
Expand Down
12 changes: 6 additions & 6 deletions local/process/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import (
)

// CreateListener creates a listener on a port
// Pass a prefered port (will increment by 1 if port is not available)
// Pass a preferred port (will increment by 1 if port is not available)
// or pass 0 to auto-find any available port
func CreateListener(preferedPort int) (net.Listener, int, error) {
func CreateListener(preferredPort int) (net.Listener, int, error) {
var ln net.Listener
var err error
port := preferedPort
port := preferredPort
max := 50
for {
// we really want to test availability on 127.0.0.1
Expand All @@ -45,16 +45,16 @@ func CreateListener(preferedPort int) (net.Listener, int, error) {
break
}
}
if preferedPort == 0 {
if preferredPort == 0 {
return nil, 0, errors.Wrap(err, "unable to find an available port")
}
max--
if max == 0 {
return nil, 0, errors.Wrapf(err, "unable to find an available port (from %d to %d)", preferedPort, port)
return nil, 0, errors.Wrapf(err, "unable to find an available port (from %d to %d)", preferredPort, port)
}
port++
}
if preferedPort == 0 {
if preferredPort == 0 {
port = ln.Addr().(*net.TCPAddr).Port
}
return ln, port, nil
Expand Down
28 changes: 14 additions & 14 deletions local/project/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ import (

// Config is the struct taken by New (should not be used for anything else)
type Config struct {
HomeDir string
ProjectDir string
DocumentRoot string `yaml:"document_root"`
Passthru string `yaml:"passthru"`
PreferedPort int `yaml:"prefered_port"`
PKCS12 string `yaml:"p12"`
Logger zerolog.Logger
AppVersion string
AllowHTTP bool `yaml:"allow_http"`
NoTLS bool `yaml:"no_tls"`
Daemon bool `yaml:"daemon"`
HomeDir string
ProjectDir string
DocumentRoot string `yaml:"document_root"`
Passthru string `yaml:"passthru"`
PreferredPort int `yaml:"preferred_port"`
PKCS12 string `yaml:"p12"`
Logger zerolog.Logger
AppVersion string
AllowHTTP bool `yaml:"allow_http"`
NoTLS bool `yaml:"no_tls"`
Daemon bool `yaml:"daemon"`
}

type FileConfig struct {
Expand Down Expand Up @@ -85,10 +85,10 @@ func NewConfigFromContext(c *console.Context, projectDir string) (*Config, *File
config.Passthru = c.String("passthru")
}
if c.IsSet("port") {
config.PreferedPort = c.Int("port")
config.PreferredPort = c.Int("port")
}
if config.PreferedPort == 0 {
config.PreferedPort = 8000
if config.PreferredPort == 0 {
config.PreferredPort = 8000
}
if c.IsSet("allow-http") {
config.AllowHTTP = c.Bool("allow-http")
Expand Down
12 changes: 6 additions & 6 deletions local/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ func New(c *Config) (*Project, error) {
homeDir: c.HomeDir,
projectDir: c.ProjectDir,
HTTP: &lhttp.Server{
DocumentRoot: documentRoot,
PreferedPort: c.PreferedPort,
Logger: c.Logger,
PKCS12: c.PKCS12,
AllowHTTP: c.AllowHTTP,
Appversion: c.AppVersion,
DocumentRoot: documentRoot,
PreferredPort: c.PreferredPort,
Logger: c.Logger,
PKCS12: c.PKCS12,
AllowHTTP: c.AllowHTTP,
Appversion: c.AppVersion,
},
}
if err != nil {
Expand Down

0 comments on commit 503c5ef

Please sign in to comment.