Esempio n. 1
0
func main() {
	logSetup := utils.NewDefaultLogSetup(serverLog)
	logSetup.SetupLogging()
	go utils.ListenForLogSignal(logSetup)

	router := mux.NewRouter()

	// add subway stuffs to server
	sconfig := NewConfig(subwayConfig)
	setupSubway(router, sconfig, subwayWeb, "subway.jprbnsn.com")
	setupSubway(router, sconfig, subwayWeb, "wheresthetrain.nyc")
	setupSubway(router, sconfig, subwayWeb, "www.wheresthetrain.nyc")
	setupSubway(router, sconfig, subwayWeb, "wtt.nyc")
	setupSubway(router, sconfig, subwayWeb, "www.wtt.nyc")
	setupSubway(router, sconfig, wheresLWeb, "wheresthel.com")
	setupSubway(router, sconfig, wheresLWeb, "www.wheresthel.com")

	// add subway stuffs to server
	// add the countdown
	countdownRouter := router.Host("countdown.jprbnsn.com").Subrouter()
	countdownRouter.PathPrefix("/").Handler(http.FileServer(http.Dir("/opt/jp/www/thecountdown")))

	// add wg4gl
	setupWG4GL(router, "wg4gl.com")
	setupWG4GL(router, "www.wg4gl.com")

	setupColin(router, "colinjhiggins.com")
	setupColin(router, "www.colinjhiggins.com")

	setupJP(router, "jprbnsn.com")
	setupJP(router, "www.jprbnsn.com")

	// newshound API setup
	nconfig := NewConfig(houndConfig)
	newshoundAPI := api.NewNewshoundAPI(nconfig.DBURL, nconfig.DBUser, nconfig.DBPassword)
	// add newshound subdomain to webserver
	newshoundRouter := router.Host("newshound.jprbnsn.com").Subrouter()
	// add newshound's API to the subdomain
	newshoundAPIRouter := newshoundRouter.PathPrefix(newshoundAPI.UrlPrefix()).Subrouter()
	newshoundAPI.Handle(newshoundAPIRouter)
	// add newshound UI to to the subdomain
	newshoundRouter.PathPrefix("/").Handler(http.FileServer(http.Dir(newshoundWeb)))

	// add newshound barkd websockets
	barkdRouter := router.Host("newshound.jprbnsn.com:8888").Subrouter()
	barkdURL, _ := url.Parse("http://127.0.0.1:8888")
	barkdRouter.PathPrefix("/").Handler(httputil.NewSingleHostReverseProxy(barkdURL))

	handler := web.AccessLogHandler(accessLog, router)

	log.Fatal(http.ListenAndServe(":80", handler))
}
Esempio n. 2
0
func main() {
	config := newshound.NewConfig()

	logSetup := utils.NewDefaultLogSetup(newshound.ServerLog)
	logSetup.SetupLogging()
	go utils.ListenForLogSignal(logSetup)

	router := mux.NewRouter()

	api := api.NewNewshoundAPI(config.DBURL, config.DBUser, config.DBPassword)
	apiRouter := router.PathPrefix(api.UrlPrefix()).Subrouter()
	api.Handle(apiRouter)

	staticRouter := router.PathPrefix("/").Subrouter()
	staticRouter.PathPrefix("/").Handler(http.FileServer(http.Dir(newshound.WebDir)))

	handler := web.AccessLogHandler(newshound.AccessLog, router)

	log.Fatal(http.ListenAndServe(":8080", handler))
}