feat: Introduce env for bind address
This commit is contained in:
parent
cda0a8f737
commit
5fb29668c8
2 changed files with 7 additions and 2 deletions
|
@ -6,4 +6,5 @@
|
|||
|
||||
Environmental variables:
|
||||
- `SHORTEN_HOST` - hostname
|
||||
- `SHORTEN_BIND` - bind address (default: `127.0.0.1:4488`)
|
||||
- `POSTGRES_URI` - lib/pq connection string (see [here](https://pkg.go.dev/github.com/lib/pq#section-documentation))
|
6
main.go
6
main.go
|
@ -71,7 +71,11 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
panic(http.ListenAndServe("127.0.0.1:4488", &Handler{db: db}))
|
||||
bind := os.Getenv("SHORTEN_BIND")
|
||||
if bind == "" {
|
||||
bind = "127.0.0.1:4488"
|
||||
}
|
||||
panic(http.ListenAndServe(bind, &Handler{db: db}))
|
||||
}
|
||||
|
||||
type Handler struct {
|
||||
|
|
Loading…
Reference in a new issue