Skip to content

Commit

Permalink
Make port configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
raphink committed Jul 27, 2017
1 parent bae3ae3 commit fc4eaef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
type Config struct {
Version bool `short:"V" long:"version" description:"Display version."`

Port int `short:"p" long:"port" description:"Port to listen on." default:"8080"`

DB struct {
Host string `long:"db-host" env:"DB_HOST" description:"Database host." default:"db"`
User string `long:"db-user" env:"DB_USER" description:"Database user." default:"gorm"`
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"io"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -105,5 +106,5 @@ func main() {
http.HandleFunc(util.AddBase("api/attribute/keys"), handleWithDB(api.ListAttributeKeys, database))

// Start server
log.Fatal(http.ListenAndServe(":8080", nil))
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", c.Port), nil))
}

0 comments on commit fc4eaef

Please sign in to comment.