예제 #1
0
파일: s3s.go 프로젝트: khaiql/instagram-go
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))
}
예제 #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()))
}
예제 #3
0
파일: main.go 프로젝트: khaiql/instagram-go
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))
}
예제 #4
0
파일: db.go 프로젝트: khaiql/instagram-go
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)
	}
}
예제 #5
0
func init() {
	godotenv.Load()
}