-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (35 loc) · 1.07 KB
/
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
38
39
40
41
package main
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/renanberto/air-voice/domain/speak"
"github.com/renanberto/air-voice/internal/handlers"
"github.com/renanberto/air-voice/internal/repository"
"net/http"
"time"
)
func NewHttpHandler() *gin.Engine {
httpHandler := gin.Default()
httpHandler.GET("/health", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message:": "OK"})
})
httpHandler.Use(cors.New(cors.Config{
AllowAllOrigins: true,
AllowMethods: []string{"POST", "GET", "DELETE", "PUT", "OPTIONS", "PATCH"},
AllowHeaders: []string{"Authorization", "Content-Type"},
ExposeHeaders: []string{"*"},
AllowCredentials: true,
MaxAge: 24 * time.Hour,
}))
return httpHandler
}
func main() {
handler := NewHttpHandler()
// Repositories
mysqlRepository := repository.NewMysqlRepository()
speechRepository := repository.NewSpeechRepository()
// UseCases
speakUseCase := speak.NewSpeaKByID(mysqlRepository, speechRepository)
handlers.NewSpeakHandler(handler, speakUseCase)
handler.Run(":4000")
}