-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
37 lines (30 loc) · 872 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"os"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"github.com/kaleabAlemayehu/foodopia/handlers"
)
func main() {
err := godotenv.Load(".env")
if err != nil {
panic("error to load .env file")
}
port := os.Getenv("GIN_PORT")
r := gin.Default()
// r.Use(cors.New(
// cors.Config{
// AllowOrigins: []string{"http://localhost:3000"},
// AllowMethods: []string{"POST", "GET", "OPTIONS"},
// AllowHeaders: []string{"Origin", "Content-Type", "Authorization"},
// ExposeHeaders: []string{"Content-Length"},
// AllowCredentials: true,
// MaxAge: 12 * time.Hour,
// }))
r.POST("/signup", handlers.Signup)
r.POST("/login", handlers.Login)
r.POST("/upload", handlers.Upload)
r.POST("/welcome", handlers.SendEmail)
r.GET("/images/*filepath", handlers.ServeImage)
r.Run(":" + port)
}