func main() { flag.Parse() if arguments.pprof { log.Println("pprof enabled") go func() { log.Println(http.ListenAndServe("localhost:6060", nil)) }() fp, err := os.Create("backend.pprof") if err != nil { panic(err) } defer fp.Close() pprof.StartCPUProfile(fp) defer pprof.StopCPUProfile() } if err := loadTree(arguments.tree); err != nil { log.Println(err) os.Exit(-1) } http.Handle("/", http.FileServer(http.Dir(arguments.web))) http.Handle("/render", websocket.Handler(renderServer)) log.Println("waiting for connections...") if err := http.ListenAndServe(fmt.Sprintf(":%v", arguments.port), nil); err != nil { log.Println(err) os.Exit(-1) } }
func main() { flag.Parse() tempLog = temperatureLog{LogSize: 0, MaxLogSize: maxLogSize, Data: make([]temperatureLogEntry, 2)} tempLog.Data[0] = temperatureLogEntry{Label: "Boiler", Values: make([]temperatureLogValue, 0)} tempLog.Data[1] = temperatureLogEntry{Label: "Grouphead", Values: make([]temperatureLogValue, 0)} go h.broadcastLoop() if devMode { go devLoop() } else { go serialLoop() } http.HandleFunc("/buffer.json", bufferHandler) http.HandleFunc("/flush", flushHandler) http.Handle("/events", websocket.Handler(eventServer)) http.Handle("/", http.FileServer( &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: "views"})) portString := fmt.Sprintf(":%d", port) err := http.ListenAndServe(portString, nil) if err != nil { log.Fatal("ListenAndServe: ", err) } }
func Start() { timeStart = time.Now() templates = template.Must(template.ParseFiles("www/index.html")) cfgCtrl := srv.Cfg().Get("server") sessionkey := cfgCtrl.Get("sessionkey").String() http.Handle("/rpc/", seshcookie.NewSessionHandler(&RpcHandler{}, sessionkey, nil)) http.Handle("/upload", seshcookie.NewSessionHandler(&UploadHandler{}, sessionkey, nil)) //http.HandleFunc("/vfile/", vfileHandler) http.Handle("/", seshcookie.NewSessionHandler(&WebHandler{}, sessionkey, nil)) StartAuth() port := cfgCtrl.Get("port").String() if len(port) > 0 { srv.HttpListenAndServeAsync(":"+port, nil, "", "", "") } tlsport := cfgCtrl.Get("tlsport").String() if len(tlsport) > 0 && tlsport != "null" { srv.HttpListenAndServeAsync(":"+tlsport, nil, "tls_cert.pem", "tls_key.pem", "") } //srv.VersionDataDir = cfgCtrl.Get("data").String() //srv.DoRefreshVersions() }
func main() { http.Handle("/echo", websocket.Handler(echoHandler)) http.Handle("/", http.FileServer(http.Dir("./"))) if err := http.ListenAndServe(":8000", nil); err != nil { panic("ListenAndServe: " + err.Error()) } }
func main() { http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("css")))) http.Handle("/pic/", http.StripPrefix("/pic/", http.FileServer(http.Dir("pic")))) http.HandleFunc("/", surfer) http.ListenAndServe(":8080", nil) }
func main() { if err := goa.Init(goa.Config{ LoginPage: "/login.html", HashKey: []byte(hashKey), EncryptionKey: []byte(cryptoKey), CookieName: "session", PQConfig: "user=test_user password=test_pass dbname=goa", }); err != nil { log.Println(err) return } // public (no-auth-required) files http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir("public")))) // protected files, only for logged-in users http.Handle("/protected/", goa.NewHandler(http.StripPrefix("/protected/", http.FileServer(http.Dir("protected"))))) // home handler http.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { http.ServeFile(rw, req, "index.html") }) http.HandleFunc("/login.html", func(rw http.ResponseWriter, req *http.Request) { http.ServeFile(rw, req, "login.html") }) http.HandleFunc("/register.html", func(rw http.ResponseWriter, req *http.Request) { http.ServeFile(rw, req, "register.html") }) if err := http.ListenAndServeTLS(":8080", "keys/cert.pem", "keys/key.pem", nil); err != nil { log.Println(err) } }
func serve(port int) { jww.FEEDBACK.Println("Serving pages from " + helpers.AbsPathify(viper.GetString("PublishDir"))) httpFs := &afero.HttpFs{SourceFs: hugofs.DestinationFS} fileserver := http.FileServer(httpFs.Dir(helpers.AbsPathify(viper.GetString("PublishDir")))) u, err := url.Parse(viper.GetString("BaseUrl")) if err != nil { jww.ERROR.Fatalf("Invalid BaseUrl: %s", err) } if u.Path == "" || u.Path == "/" { http.Handle("/", fileserver) } else { http.Handle(u.Path, http.StripPrefix(u.Path, fileserver)) } u.Scheme = "http" jww.FEEDBACK.Printf("Web Server is available at %s\n", u.String()) fmt.Println("Press Ctrl+C to stop") err = http.ListenAndServe(":"+strconv.Itoa(port), nil) if err != nil { jww.ERROR.Printf("Error: %s\n", err.Error()) os.Exit(1) } }
func main() { flag.Parse() go hub() var err error session, err = mgo.Mongo("localhost") if err != nil { panic("main > Mongo: " + err.Error()) } defer session.Close() pfx := "/static/" h := http.StripPrefix(pfx, http.FileServer(http.Dir("../static/"))) http.Handle(pfx, h) // It is absurd I had to work that hard to serve static files. Let's shove them on AWS or something and forget about it http.HandleFunc("/tickle", doTickle) http.HandleFunc("/keys", viewKeys) http.HandleFunc("/keys/add", addKey) http.HandleFunc("/keys/check", checkKey) http.HandleFunc("/links/send", sendLink) http.HandleFunc("/register", registerHandler) http.HandleFunc("/openid/callback", openID) http.HandleFunc("/openid/callback/chrome", openID) http.HandleFunc("/users/validate", validateUser) http.HandleFunc("/logout", doLogout) http.HandleFunc("/login", doLogin) http.HandleFunc("/links/", linksList) http.HandleFunc("/", rootHandler) http.Handle("/ws", websocket.Handler(wsHandler)) if err := http.ListenAndServe(*addr, nil); err != nil { log.Fatal("ListenAndServe:", err) } }
func main() { defer db.Close() http.HandleFunc("/main", handleMain) http.HandleFunc("/demo", handleDemo) http.HandleFunc("/logout", auth.HandleLogout) http.HandleFunc("/authorize", auth.HandleAuthorize) http.HandleFunc("/oauth2callback", auth.HandleOAuth2Callback) http.HandleFunc("/categoryList/", handleCategoryList) http.HandleFunc("/category/", handleCategory) http.HandleFunc("/feed/list/", handleFeedList) http.HandleFunc("/feed/new/", handleNewFeed) http.HandleFunc("/feed/", handleFeed) http.HandleFunc("/entry/mark/", handleMarkEntry) http.HandleFunc("/entry/", handleEntry) http.HandleFunc("/entries/", handleEntries) http.HandleFunc("/menu/select/", handleSelectMenu) http.HandleFunc("/menu/", handleMenu) http.HandleFunc("/stats/", handleStats) http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static/")))) http.Handle("/favicon.ico", http.StripPrefix("/favicon.ico", http.FileServer(http.Dir("./static/favicon.ico")))) http.HandleFunc("/", handleRoot) go feed.CacheAllCats() //create cache for categories at startup go feed.CacheAllFeeds() //create cache for feeds at startup print("Listening on 127.0.0.1:" + port + "\n") http.ListenAndServe("127.0.0.1:"+port, nil) }
func main() { log.Trace("Starting") flag.Parse() if *blog_dir == "" { log.Error("Must specify a directory where blogs are stored") time.Sleep(1000) os.Exit(1) } blogs := blog.New() blogReader := reader.New(blogs, *blog_dir, log) v := view.New(blogs, log) router := router.New(v, log) err := blogReader.ReadBlogs() if err != nil { log.Error("Error creating blog reader: %s", err) time.Sleep(1000) os.Exit(1) } http.Handle("/", router) http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir("./public")))) err = http.ListenAndServe(":"+*protocol, nil) if err != nil { log.Error("Problem with http server: %s", err) time.Sleep(1000) os.Exit(1) } log.Trace("Stopping") }
func main() { addr := flag.String("addr", ":8080", "アプリケーションのアドレス") flag.Parse() gomniauth.SetSecurityKey("GoChat") gomniauth.WithProviders( google.New(googleClientID, googleSecret, "http://localhost:8080/auth/callback/google"), ) r := newRoom() r.tracer = trace.New(os.Stdout) // http.HandleFunc("/", func (w http.ResponseWriter, r *http.Request) {w.Write([]byte())}) // http.Handle("/assets/", http.StripPrefix("/assets", http.FileServer(http.Dir("/assetsへのパス")))) // *templateHandler型(templateHandlerのポインタ型)にServeHTTPが実装されている // のでtemplateHandlerのアドレスを渡してポインタである*templateHandler型を渡す http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"})) http.Handle("/login", &templateHandler{filename: "login.html"}) http.HandleFunc("/auth/", loginHandler) http.Handle("/room", r) go r.run() log.Println("Webサーバを開始します。ポート: ", *addr) // start web server if err := http.ListenAndServe(*addr, nil); err != nil { log.Fatal("ListenAndServe:", err) } }
func main() { var err error //Initialize mongodb connection, assuming mongo.go is present //If you are using another database setup, swap out this section mongodb_session, err = mgo.Dial(MONGODB_URL) if err != nil { panic(err) } mongodb_session.SetMode(mgo.Monotonic, true) mongodb_session.EnsureSafe(&mgo.Safe{1, "", 0, true, false}) defer mongodb_session.Close() r := mux.NewRouter() r.HandleFunc("/", serveHome) r.HandleFunc("/callback", serveCallback).Methods("GET") r.HandleFunc("/register", serveRegister) r.HandleFunc("/login", serveLogin) r.Handle("/profile", &authHandler{serveProfile, false}).Methods("GET") http.Handle("/static/", http.FileServer(http.Dir("public"))) http.Handle("/", r) if err := http.ListenAndServe(*httpAddr, nil); err != nil { log.Fatalf("Error listening, %v", err) } }
func serveHTTP() error { http.Handle("/", appHandler(handleStatic)) http.Handle("/input", mjpegHandler(input)) http.Handle("/output1", mjpegHandler(output1)) http.Handle("/output2", mjpegHandler(output2)) return http.ListenAndServe(*flagPort, nil) }
func main() { var portNumber int flag.IntVar(&portNumber, "port", 80, "Default port is 80") flag.Parse() // Routes to serve front-end assets r := mux.NewRouter() http.Handle("/javascripts/", http.StripPrefix("/javascripts/", http.FileServer(http.Dir("frontend/public/javascripts/")))) http.Handle("/images/", http.StripPrefix("/images/", http.FileServer(http.Dir("frontend/public/images/")))) http.Handle("/stylesheets/", http.StripPrefix("/stylesheets/", http.FileServer(http.Dir("frontend/public/stylesheets/")))) // API Endpoints r.PathPrefix(V1_PREFIX + "/run-ad-on/{service}/for/{stream}").HandlerFunc(ads.AdRequester) r.Path(V1_PREFIX + "/ping").HandlerFunc(health.Ping) // Pass to front-end r.PathPrefix(V1_PREFIX + "/stream").HandlerFunc(index) r.PathPrefix(V1_PREFIX).HandlerFunc(index) http.Handle("/", r) port := strconv.FormatInt(int64(portNumber), 10) fmt.Println("IRWIn Server starting") if err := http.ListenAndServe(":"+port, nil); err != nil { log.Fatalf("Could not start on port "+port, err) } }
func init() { r := httprouter.New() http.Handle("/", r) r.GET("/", cover) r.GET("/put", handlePut) r.GET("/get", handleGet) r.GET("/list", handleList) r.GET("/browse", browse) r.GET("/newStory", newStory) r.GET("/newScene", newScene) r.GET("/user/:name", profile) r.GET("/login", login) r.GET("/signup", signup) r.GET("/logout", logout) r.GET("/editProfile", editProfile) r.GET("/view/:story/:owner", viewStory) r.POST("/api/checkemail", checkEmail) r.POST("/api/checkusername", checkUserName) r.POST("/api/login", loginProcess) r.POST("/api/signup", createUser) r.POST("/api/editProfile", editProfileProcess) r.POST("/api/editPassword", editPassword) r.POST("/api/story", newStoryProcess) r.POST("/api/scene", newSceneProcess) http.Handle("/public/", http.StripPrefix("/public", http.FileServer(http.Dir("public/")))) tpl = template.New("roottemplate") tpl = template.Must(tpl.ParseGlob("templates/*.html")) }
func main() { var addr = flag.String("addr", ":8080", "アプリケーションのアドレス") flag.Parse() gomniauth.SetSecurityKey(signature.RandomKey(64)) gomniauth.WithProviders( google.New( os.Getenv("client_id"), os.Getenv("client_secret"), "http://localhost:8080/auth/callback/google")) r := newRoom(UseFileSystemAvatar) http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"})) http.Handle("/login", &templateHandler{filename: "login.html"}) http.HandleFunc("/logout", func(w http.ResponseWriter, r *http.Request) { http.SetCookie(w, &http.Cookie{ Name: "auth", Value: "", Path: "/", MaxAge: -1, }) w.Header().Set("Location", "/chat") w.WriteHeader(http.StatusTemporaryRedirect) }) http.HandleFunc("/auth/", loginHandler) http.Handle("/room", r) http.Handle("/upload", &templateHandler{filename: "upload.html"}) http.HandleFunc("/uploader", uploaderHandler) http.Handle("/avatars/", http.StripPrefix("/avatars/", http.FileServer(http.Dir("./avatars")))) go r.run() log.Println("Webサーバーを開始します。ポート: ", *addr) if err := http.ListenAndServe(*addr, nil); err != nil { log.Fatal("ListenAndServe:", err) } }
func main() { fmt.Println("Server address is", myAddress) var serverURI = fmt.Sprintf("%s:%d", configuration.ServerAddress, configuration.ServerPort) var isMobile = regexp.MustCompile(`(M|m)obile|(I|i)P(hone|od|ad)|(A|a)ndroid|(B|b)lackBerry|(I|i)EMobile|(K|k)indle|(N|n)etFront|(S|s)ilk-Accelerated|(hpw|web)OS|(F|f)ennec|(M|m)inimo|(O|o)pera (M|m)(obi|ini)|(B|b)lazer|(D|d)olfin|(D|d)olphin|(S|s)kyfire|(Z|z)une`) //communcation settings var newLobbyChan = make(chan *lobby) //all the new lobbies are sent over this to our hub to be registered var socketConnChan = make(chan socketEntity) //the sockets send a channel to the hub with ID for their connection. var killHubChan = make(chan entity) //used to kill lobbies etc off. This is sockets to lobby ONLY. go hub(newLobbyChan, socketConnChan, killHubChan) //spawn hub to keep track of the lobbies and answer queries about lobbies http.Handle(configuration.HTTPRoutes.Root, http.HandlerFunc( func(w http.ResponseWriter, r *http.Request) { if isMobile.MatchString(r.UserAgent()) { //if its a mobile user handleMobile(w, r) } else { handleDesktop(newLobbyChan, w, r) } })) http.Handle(configuration.HTTPRoutes.Javascript.Route, http.StripPrefix(configuration.HTTPRoutes.Javascript.Route, http.FileServer(http.Dir(configuration.HTTPRoutes.Javascript.RootLocation)))) http.Handle(configuration.HTTPRoutes.Images.Route, http.StripPrefix(configuration.HTTPRoutes.Images.Route, http.FileServer(http.Dir(configuration.HTTPRoutes.Images.RootLocation)))) http.Handle(configuration.HTTPRoutes.Websocket, websocket.Handler( func(ws *websocket.Conn) { handleSocket(socketConnChan, killHubChan, ws) })) fmt.Println("Binding and listening on", serverURI) if err := http.ListenAndServe(serverURI, nil); err != nil { log.Fatal("ListenAndServe:", err) } }
func main() { http.HandleFunc("/", index) http.HandleFunc("/up", upload) http.HandleFunc("/del", delfile) http.Handle("/static/", http.StripPrefix("/static", http.FileServer(http.Dir("static")))) http.Handle("/i/", http.StripPrefix("/i", http.FileServer(http.Dir("i")))) config = readConfig() validateConfig(config) var wg sync.WaitGroup wg.Add(2) go func() { defer wg.Done() if config.Http.Enabled { log.Printf("Starting HTTP server on %s\n", config.Http.Listen) log.Println(http.ListenAndServe(config.Http.Listen, nil)) } }() go func() { defer wg.Done() if config.Https.Enabled { log.Printf("Starting HTTPS server on %s\n", config.Https.Listen) log.Println(http.ListenAndServeTLS(config.Https.Listen, config.Https.Cert, config.Https.Key, nil)) } }() wg.Wait() }
func routes() { http.Handle("/", PageHandler) http.Handle("/api/signup", SignupHandler) http.Handle("/api/login", LoginHandler) http.Handle("/api/logout", LogoutHandler) http.Handle("/api/websocket", WebsocketHandler) }
func main() { flag.Parse() config.SetConfig("config", *flag.String("config", "config.xml", "config xml file for start")) config.SetConfig("logfilename", *flag.String("logfilename", "/log/logfilename.log", "log file name")) config.SetConfig("deamon", *flag.String("deamon", "false", "need run as demo")) config.SetConfig("port", *flag.String("port", "8000", "http port ")) config.SetConfig("log", *flag.String("log", "debug", "logger level ")) config.LoadFromFile(config.GetConfigStr("config"), "global") if err := config.LoadFromFile(config.GetConfigStr("config"), "MobileLogServer"); err != nil { fmt.Println(err) return } monitorMap = make(map[*websocket.Conn]*websocket.Conn) logger, err := logging.NewTimeRotationHandler(config.GetConfigStr("logfilename"), "060102-15") if err != nil { fmt.Println(err) return } logger.SetLevel(logging.DEBUG) logging.AddHandler("MLOG", logger) logging.Info("server startin...") http.Handle("/ws", websocket.Handler(MonitorServer)) http.Handle("/", http.FileServer(http.Dir("."))) http.HandleFunc("/log/fxsj", LogServer) http.HandleFunc("/log/hxsg", LogServer) http.HandleFunc("/testlua", testLua) http.HandleFunc("/log/sbjs", LogServer) err = http.ListenAndServe(config.GetConfigStr("ip")+":"+config.GetConfigStr("port"), nil) if err != nil { fmt.Println(err) logging.Error("ListenAndServe:%s", err.Error()) } logging.Info("server stop...") }
func main() { SetCues() conns = list.New() http.Handle("/chat", websocket.Handler(Chat)) http.Handle("/", http.FileServer(http.Dir("./html"))) http.ListenAndServe(":8080", nil) }
func init() { initTemplate() http.HandleFunc("/", rootHandler) http.HandleFunc("/find/", findHandler) http.Handle("/css/", http.FileServer(http.Dir("."))) http.Handle("/js/", http.FileServer(http.Dir("."))) }
func setupDaemon(port int) { router := mux.NewRouter() router.HandleFunc("/", HomeHandler) http.Handle("/", router) http.Handle("/static/", http.FileServer(http.Dir("."))) restHandler := rest.ResourceHandler{} restHandler.SetRoutes( rest.Route{"GET", "/api/test", RestTest}, ) restHandler.EnableGzip = true restHandler.EnableLogAsJson = true restHandler.EnableResponseStackTrace = true restHandler.EnableStatusService = true http.Handle("/api/", &restHandler) err := http.ListenAndServe(fmt.Sprintf(":%d", port), handlers.CombinedLoggingHandler(os.Stdout, http.DefaultServeMux)) if err != nil { log.Fatalln(err) } }
func NewSchemaInfo(queryCacheSize int, reloadTime time.Duration, idleTimeout time.Duration, sensitiveMode bool) *SchemaInfo { si := &SchemaInfo{ queryCacheSize: queryCacheSize, queries: cache.NewLRUCache(int64(queryCacheSize)), rules: NewQueryRules(), connPool: NewConnectionPool("", 2, idleTimeout), reloadTime: reloadTime, ticks: timer.NewTimer(reloadTime), sensitiveMode: sensitiveMode, } stats.Publish("QueryCacheLength", stats.IntFunc(si.queries.Length)) stats.Publish("QueryCacheSize", stats.IntFunc(si.queries.Size)) stats.Publish("QueryCacheCapacity", stats.IntFunc(si.queries.Capacity)) stats.Publish("QueryCacheOldest", stats.StringFunc(func() string { return fmt.Sprintf("%v", si.queries.Oldest()) })) stats.Publish("SchemaReloadTime", stats.DurationFunc(func() time.Duration { return si.reloadTime })) stats.Publish("TableStats", stats.NewMatrixFunc("Table", "Stats", si.getTableStats)) stats.Publish("TableInvalidations", stats.CountersFunc(si.getTableInvalidations)) stats.Publish("QueryCounts", stats.NewMatrixFunc("Table", "Plan", si.getQueryCount)) stats.Publish("QueryTimesNs", stats.NewMatrixFunc("Table", "Plan", si.getQueryTime)) stats.Publish("QueryRowCounts", stats.NewMatrixFunc("Table", "Plan", si.getQueryRowCount)) stats.Publish("QueryErrorCounts", stats.NewMatrixFunc("Table", "Plan", si.getQueryErrorCount)) // query_plans cannot be shown in sensitive mode if !si.sensitiveMode { http.Handle("/debug/query_plans", si) } http.Handle("/debug/query_stats", si) http.Handle("/debug/table_stats", si) http.Handle("/debug/schema", si) return si }
func init() { http.Handle("/debug/pprof/", http.HandlerFunc(Index)) http.Handle("/debug/pprof/cmdline", http.HandlerFunc(Cmdline)) http.Handle("/debug/pprof/profile", http.HandlerFunc(Profile)) http.Handle("/debug/pprof/symbol", http.HandlerFunc(Symbol)) http.Handle("/debug/pprof/trace", http.HandlerFunc(Trace)) }
func Start(port string, onStart func()) { // Logging init flag.Set("log_dir", utils.GetRuntimeDir(config.GetString("log_dir"))) flag.Set("alsologtostderr", "true") flag.Parse() defer glog.Flush() m := martini.Classic() m.Use(render.Renderer(render.Options{ Charset: "UTF-8", // Sets encoding for json and html content-types. Default is "UTF-8". Delims: render.Delims{"${", "}"}, Directory: utils.GetRuntimeDir("resources/views"), })) m.Use(martini.Static(utils.GetRuntimeDir("public"))) controller.MappingController(m) http.Handle("/rpc", rpc.GetServer()) http.Handle("/", m) if db.IsConnected() { defer db.Close() } onStart() for _, fn := range methods { go fn() } http.ListenAndServe(":"+port, nil) }
func main() { http.Handle("/string", String("I'm a frayed knot.")) http.Handle("/struct", &Struct{"Hello", ":", "Gophers!"}) log.Fatal(http.ListenAndServe("localhost:4000", nil)) }
func Bloat() { stmt, err := database.Prepare("INSERT INTO new (code) VALUES (?)") if err != nil { fmt.Println(err) return } http.Handle("/", engine(BloatHandler)) http.Handle("/card", engine(CardHandler)) codec := CodePool() notifier := shutdown.First() for { select { case code := <-codec: database.Lock() stmt.Exec(string(code)) database.Unlock() case n := <-notifier: stmt.Close() close(n) return } } }
func serve(port int) { jww.FEEDBACK.Println("Serving pages from " + helpers.AbsPathify(viper.GetString("PublishDir"))) httpFs := &afero.HttpFs{SourceFs: hugofs.DestinationFS} fs := filesOnlyFs{httpFs.Dir(helpers.AbsPathify(viper.GetString("PublishDir")))} fileserver := http.FileServer(fs) // We're only interested in the path u, err := url.Parse(viper.GetString("BaseURL")) if err != nil { jww.ERROR.Fatalf("Invalid BaseURL: %s", err) } if u.Path == "" || u.Path == "/" { http.Handle("/", fileserver) } else { http.Handle(u.Path, http.StripPrefix(u.Path, fileserver)) } u.Scheme = "http" jww.FEEDBACK.Printf("Web Server is available at %s (bind address %s)\n", u.String(), serverInterface) fmt.Println("Press Ctrl+C to stop") endpoint := net.JoinHostPort(serverInterface, strconv.Itoa(port)) err = http.ListenAndServe(endpoint, nil) if err != nil { jww.ERROR.Printf("Error: %s\n", err.Error()) os.Exit(1) } }
func main() { rand.Seed(time.Now().Unix()) var port string if len(os.Args) < 2 { port = "80" } else { port = os.Args[1] } log.Printf("Port number to listen on = %s\n", port) http.Handle("/status/", http.HandlerFunc(status.Status)) http.Handle("/logon", http.HandlerFunc(config.CloudLogon)) http.Handle("/getMachine", http.HandlerFunc(config.GetMachineAccount)) http.Handle("/connect", http.HandlerFunc(config.Connect)) http.Handle("/dmcConfig", http.HandlerFunc(config.DmcConfig)) http.Handle("/getBearerForMachine", http.HandlerFunc(config.GetBearerForMachine)) http.Handle("/getRealToken", http.HandlerFunc(config.GetRealToken)) //debug related items - intended to aid in standalone, test environment http.Handle("/config/", http.HandlerFunc(config.Config)) http.Handle("/logmeon", http.HandlerFunc(config.LogMeOn)) http.Handle("/token", http.HandlerFunc(config.Token)) chan1 := make(chan bool) go httpListener(port, chan1) go httpTlsListener(chan1) select { case <-chan1: log.Printf("\n\nDetected context done\n\n") } log.Printf("goodbye\n") }