aboutsummaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2020-05-28 22:14:46 +0700
committerShulhan <m.shulhan@gmail.com>2020-05-28 22:46:08 +0700
commit5d49371ef3f5cc1fa4d4fd6d5d84207520739037 (patch)
tree284cfe0c442788409fbe71a9b950a84a26614355 /server.go
parent9ddee4a05e38d0b71b8b2628c0ebba98ad7c5470 (diff)
downloadkamusku-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.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/server.go b/server.go
index e3ed460..ef7f930 100644
--- a/server.go
+++ b/server.go
@@ -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 {