Add support for PORT env variable

This commit is contained in:
emersion 2017-09-09 16:13:26 +02:00
parent 5e0754d0a1
commit 3086fc8297
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 7 additions and 1 deletions

View File

@ -6,6 +6,7 @@ A third-party, open-source ProtonMail CardDAV bridge.
Your credentials will be stored on disk encrypted with a 32-byte random
password. When configuring your CardDAV client, you'll need this password.
You must setup an HTTPS reverse proxy to forward requests to `hydroxide`.
```shell
go get github.com/emersion/hydroxide

View File

@ -207,10 +207,15 @@ func main() {
fmt.Println("Bridge password:", bridgePassword)
case "":
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
sessions := make(map[string]*session)
s := &http.Server{
Addr: "127.0.0.1:8080",
Addr: "127.0.0.1:"+port,
Handler: http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
resp.Header().Set("WWW-Authenticate", "Basic")