Beispiel #1
0
func main() {
	// Select("users")
	r := mux.NewRouter()
	r.HandleFunc("/Users", InsertUser)
	http.ListenAndServe(":5000", r)

}
Beispiel #2
0
func initRouting() *mux.Router {

	r := mux.NewRouter()

	r.HandleFunc("/", indexHandler)
	r.HandleFunc("/all", indexHandler)
	r.HandleFunc("/active", activeIndexHandler)
	r.HandleFunc("/completed", completedIndexHandler)
	r.HandleFunc("/new", newHandler)
	r.HandleFunc("/toggle/{id}", toggleHandler)
	r.HandleFunc("/delete/{id}", deleteHandler)
	r.HandleFunc("/clear", clearHandler)

	// Add handler for websocket server
	r.Handle("/ws/all", newChangesHandler(allChanges))
	r.Handle("/ws/active", newChangesHandler(activeChanges))
	r.Handle("/ws/completed", newChangesHandler(completedChanges))

	// Add handler for static files
	r.PathPrefix("/").Handler(http.FileServer(http.Dir("static")))

	return r
}
func main() {
	r := mux.NewRouter()
	r.HandleFunc("/Users", UserUtils)
	http.ListenAndServe(":5000", r)
}