diff options
| author | Shulhan <m.shulhan@gmail.com> | 2020-05-28 22:14:46 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2020-05-28 22:46:08 +0700 |
| commit | 5d49371ef3f5cc1fa4d4fd6d5d84207520739037 (patch) | |
| tree | 284cfe0c442788409fbe71a9b950a84a26614355 /server.go | |
| parent | 9ddee4a05e38d0b71b8b2628c0ebba98ad7c5470 (diff) | |
| download | kamusku-5d49371ef3f5cc1fa4d4fd6d5d84207520739037.tar.xz | |
server: make the listen port configurable through environment
Deploying to App Engine require the port to be initialized through
environment variable PORT.
Diffstat (limited to 'server.go')
| -rw-r--r-- | server.go | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -49,9 +49,15 @@ type Server struct { // storage. // func NewServer(kamusStorage string) (server *Server, err error) { + address := defListen + port := os.Getenv(envPort) + if len(port) > 0 { + address = ":" + port + } + opts := &http.ServerOptions{ - Root: defRootDir, - Address: defListen, + Root: "", + Address: address, } if debug.Value > 0 { |
