Exemplo n.º 1
0
func init() {
	godotenv.Load()
	// err := godotenv.Load()
	// if err != nil {
	// 	log.Fatal("Error loading .env file")
	// }

	BUCKET = aws.String(os.Getenv("BUCKET"))

	SVC = s3.New(aws.NewConfig().WithRegion(os.Getenv("AWS_REGION")).WithS3ForcePathStyle(true))
}
Exemplo n.º 2
0
func main() {
	defer db.Close()
	godotenv.Load()

	if os.Getenv("ENV") != "production" {
		factory.AutoMigrate()
		s3s.Test()
	} else {
		log.Println("Production")
	}

	log.Fatal(http.ListenAndServe(":"+os.Getenv("PORT"), api_srv.New()))
}
Exemplo n.º 3
0
func main() {
	defer db.Close()
	godotenv.Load()

	if os.Getenv("ENV") != "production" {
		factory.AutoMigrate()
		s3s.Test()
	} else {
		log.Println("Production")
	}

	// Route settings
	router := mux.NewRouter().StrictSlash(true)

	router.
		HandleFunc("/user", handlers.Register).
		Methods("POST")

	router.
		HandleFunc("/user/login", handlers.Login).
		Methods("GET")

	router.
		HandleFunc("/user/{userId}", handlers.GetUserById).
		Methods("GET")

	router.
		HandleFunc("/user/{userId}/photos", handlers.GetPhotosByUserId).
		Methods("GET")

	router.
		HandleFunc("/user/{userId}", handlers.UpdateUser).
		Methods("POST")

	router.
		HandleFunc("/photos", handlers.GetPhotos).
		Methods("GET")

	router.
		HandleFunc("/photo", handlers.PostPhoto).
		Methods("POST")

	router.
		HandleFunc("/photo/{photoId}/comment", handlers.CreateComment).
		Methods("POST")

	// Bind to a port and pass our router in
	http.Handle("/", &MyServer{router})

	log.Fatal(http.ListenAndServe(":"+os.Getenv("PORT"), nil))
}
Exemplo n.º 4
0
func init() {
	godotenv.Load()

	connString := getStandardizedConnStr(os.Getenv("CLEARDB_DATABASE_URL"))
	// log.Println(connString)

	Conn, _ = gorm.Open("mysql", connString)
	Conn.SingularTable(true)
	log.Println(Conn.DB().Ping())

	if os.Getenv("ENV") != "production" {
		Conn.LogMode(true)
	}
}
Exemplo n.º 5
0
func init() {
	godotenv.Load()
}