Skip to content
This repository was archived by the owner on Sep 4, 2018. It is now read-only.

Commit

Permalink
add ssl support
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuckkuck committed Jan 6, 2015
1 parent 2e6d142 commit 0d4ac12
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,37 @@ func NewHub() *Hub {
func main() {
sseString := os.Getenv("SSE_HOST")
if sseString == "" {
log.Fatal("SSE_HOST is not set, example: SSE_HOST=localhost:3000")
log.Fatal("SSE_HOST is not set, example: SSE_HOST=localhost:3000 for non SSL or SSE_HOST=localhost:3001 for SSL. Please set SSL_KEY and SSL_CERT to full path of priv key and cert")
}
log.Println("[Info] botbot-eventsource is listening on " + sseString)

log.Println("[Info] Starting the eventsource Hub")
h := NewHub()

// eventsource endpoints
http.HandleFunc(ssePath, h.EventSourceHandler)

log.Fatalln(http.ListenAndServe(sseString, nil))
if sseString ~= "3000" {

log.Println("[Info] botbot-eventsource is listening on " + sseString)

log.Println("[Info] Starting the eventsource Hub")
h := NewHub()

// eventsource endpoints
http.HandleFunc(ssePath, h.EventSourceHandler)

log.Fatalln(http.ListenAndServe(sseString, nil))
}
else if sslKey == "" {
log.Fatal("SSL_KEY is not set, set it to full path to key file")
}
else if sslCert == "" {
log.Fatal("SSL_CERT is not set, set it to full path to cert file")
}
else {
sslKey := os.Getenv("SSL_KEY")
sslCert := os.Getenv("SSL_CERT")

log.Println("[Info] botbot-eventsource is listening on " + sseString)

log.Println("[Info] Starting the eventsource Hub")
h := NewHub()

// eventsource endpoints
http.HandleFunc(ssePath, h.EventSourceHandler)
log.Fatalln(http.ListenAndServeTLS(SSE_HOST, SSL_CERT, SSL_KEY, nil))
}
}

0 comments on commit 0d4ac12

Please sign in to comment.