committed by
Emile Vauge
parent
396480734c
commit
c039b48727
9
app.go
9
app.go
@ -7,7 +7,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
// "github.com/pkg/profile"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -16,9 +15,13 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var cert string
|
||||||
|
var key string
|
||||||
var port string
|
var port string
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
flag.StringVar(&cert, "cert", "", "give me a certificate")
|
||||||
|
flag.StringVar(&key, "key", "", "give me a key")
|
||||||
flag.StringVar(&port, "port", "80", "give me a port number")
|
flag.StringVar(&port, "port", "80", "give me a port number")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +31,6 @@ var upgrader = websocket.Upgrader{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// defer profile.Start().Stop()
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
http.HandleFunc("/echo", echoHandler)
|
http.HandleFunc("/echo", echoHandler)
|
||||||
http.HandleFunc("/bench", benchHandler)
|
http.HandleFunc("/bench", benchHandler)
|
||||||
@ -36,6 +38,9 @@ func main() {
|
|||||||
http.HandleFunc("/api", api)
|
http.HandleFunc("/api", api)
|
||||||
http.HandleFunc("/health", healthHandler)
|
http.HandleFunc("/health", healthHandler)
|
||||||
fmt.Println("Starting up on port " + port)
|
fmt.Println("Starting up on port " + port)
|
||||||
|
if len(cert) > 0 && len(key) > 0 {
|
||||||
|
log.Fatal(http.ListenAndServeTLS(":"+port, cert, key, nil))
|
||||||
|
}
|
||||||
log.Fatal(http.ListenAndServe(":"+port, nil))
|
log.Fatal(http.ListenAndServe(":"+port, nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user