Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Fixes #1031: Adds code to set RESTful API address correctly and use i…
Browse files Browse the repository at this point in the history
…t when starting the RESTful server
  • Loading branch information
Tom McSweeney committed Jun 27, 2016
1 parent d29748b commit 558af15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mgmt/rest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@ func New(cfg *Config) (*Server, error) {
cpath := cfg.RestCertificate
kpath := cfg.RestKey
s := &Server{
err: make(chan error),
killChan: make(chan struct{}),
err: make(chan error),
killChan: make(chan struct{}),
addrString: cfg.Address,
}
if https {
var err error
Expand Down
7 changes: 7 additions & 0 deletions snapd.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,13 @@ func applyCmdLineFlags(cfg *Config, ctx *cli.Context) {
cfg.RestAPI.Port = cmdLinePort
} else if cfgFilePortInAddr {
cfg.RestAPI.Port = cfgFilePort
} else {
// if get to here, then there is no port number in the input address
// (regardless of whether it came from the default configuration, configuration
// file, an environment variable, or a command-line flag); in that case we should
// set the address in the RestAPI configuration to be the current address and port
// (separated by a ':')
cfg.RestAPI.Address = fmt.Sprintf("%v:%v", cfg.RestAPI.Address, cfg.RestAPI.Port)
}
}

Expand Down

0 comments on commit 558af15

Please sign in to comment.