package server import ( "fmt" "net/http" "time" ) func (srv *server) ListenToRequests() { h := srv.actions mux := http.NewServeMux() server := &http.Server{ Addr: fmt.Sprintf("localhost:%s", srv.config.ServerConfig.Port), Handler: h.GetSession(mux), ReadTimeout: time.Second * 5, WriteTimeout: time.Second * 5, } fs := http.FileServer(http.Dir("assets/")) mux.Handle("GET /assets/", http.StripPrefix("/assets/", fs)) mux.HandleFunc("GET /ping", h.Ping) mux.HandleFunc("GET /", h.MainPage) mux.HandleFunc("POST /", h.HandleForm) mux.HandleFunc("POST /done", h.HandleDoneAction) mux.HandleFunc("POST /login", h.HandleLogin) mux.HandleFunc("POST /signup", h.HandleSignup) // ====== elements ====== mux.HandleFunc("GET /showform", h.ServeShowForm) mux.HandleFunc("GET /hideform", h.ServeHideForm) fmt.Printf("Listening on %v\n", server.Addr) server.ListenAndServe() }