You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
548B

  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. )
  6. type httpEntry func(http.ResponseWriter, *http.Request)
  7. var httpEntryMap = map[string]httpEntry{
  8. apiV1Prefix: apiV1Main,
  9. apiV1WebSocket: apiV1WebSocketHandler,
  10. }
  11. func setupHTTPHandler() {
  12. for key, val := range httpEntryMap {
  13. http.HandleFunc(key, val)
  14. }
  15. log.Printf("Server started at %s:%s\n", config.Host, config.Port)
  16. log.Fatal(http.ListenAndServe(config.Host+":"+config.Port, nil))
  17. //log.Fatal(http.ListenAndServeTLS(config.Host+":"+config.Port, config.TlsCert, config.TlsKey, nil))
  18. }