func main() { conf.Parse() restrict.ReadCryptoKey("keys/app.rsa") router := mux.NewRouter() router.HandleFunc("/users", GetUserHandler).Methods("GET") router.HandleFunc("/users/login", LoginHandler).Methods("POST") router.HandleFunc("/users/register", RegisterHandler).Methods("POST") router.HandleFunc("/classes", restrict.R(CreateClassHandler)).Methods("POST") router.HandleFunc("/classes", restrict.R(GetClassesHandler)).Methods("GET") router.HandleFunc("/classes/{class_id}/workshops", restrict.R(CreateWorkshopHandler)).Methods("POST") router.HandleFunc("/classes/{class_id}/workshops/{workshop_id}/pages", restrict.R(CreateWorkshopPageHandler)).Methods("POST") router.HandleFunc("/classes/{class_id}/workshops/{workshop_id}/pages", restrict.R(GetWorkshopPagesHandler)).Methods("GET") router.HandleFunc("/classes/{class_id}/workshops/{workshop_id}/pages/{page_id}/edit", restrict.R(EditPageHandler)).Methods("POST") router.HandleFunc("/classes/{class_id}/workshops/{workshop_id}", restrict.R(GetWorkshopHandler)).Methods("GET") router.HandleFunc("/classes/{class_id}/workshops/{workshop_id}", restrict.R(EditWorkshopHandler)).Methods("PUT") router.HandleFunc("/classes/{class_id}/workshops/{workshop_id}", restrict.R(DeleteWorkshopHandler)).Methods("DELETE") router.HandleFunc("/classes/{class_id}/workshops", restrict.R(GetWorkshopsHandler)).Methods("GET") router.HandleFunc("/classes/{class_id}/students", restrict.R(GetStudentHandler)).Methods("GET") router.HandleFunc("/classes/{class_id}/image", restrict.R(SetClassImageHandler)).Methods("POST") router.HandleFunc("/classes/{class_id}/admin/students", restrict.R(AddUserToClassHandler)).Methods("POST") n := negroni.New() n.Use(negroni.NewStatic(http.Dir("static"))) n.Use(negroni.NewLogger()) n.UseHandler(router) models.InitDB(*dbFile) http.ListenAndServe("localhost:8080", n) }
func main() { conf.Use(configure.NewEnvironment()) conf.Use(configure.NewFlag()) conf.Parse() restrict.ReadCryptoKey(*crypto) models.Init( *dbUser, *dbPass, *dbService, *dbPort, *dbName, ) fmt.Println("Welcome to pay.") r := mux.NewRouter().PathPrefix("/api").Subrouter().StrictSlash(true) r.HandleFunc("/ping", restrict.R(pingHandler)). Methods("GET") r.HandleFunc("/users", registerHandler). Methods("POST") r.HandleFunc("/users", loginHandler). Methods("GET") fmt.Println(http.ListenAndServe(":8080", r)) }
func main() { var err error sentry, err = raven.NewClient(*sentryDSN, nil) if err != nil { log.Println("No sentry:", err) } restrict.ReadCryptoKey(*crypto) models.Init( *dbUser, *dbPass, *dbService, *dbPort, *dbName, ) go tunnel.NewRPCServer(messages, *rpcAddr, *rpcPort) go messageLoop() r := setupRouting() pool = setupZombies() log.Println(gracehttp.Serve( &http.Server{ Addr: *httpAddr + ":" + *httpPort, Handler: r, }, )) }