-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
72 lines (54 loc) · 1.69 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"net/http"
"github.com/MohammadMobasher/resturan-backend/routes"
"github.com/MohammadMobasher/resturan-backend/routes/middleware"
"github.com/gin-gonic/gin"
_ "github.com/MohammadMobasher/resturan-backend/docs"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
)
// @title Gin Swagger Example API
// @version 1.0
// @description resturan
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email [email protected]
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:8080
// @BasePath /
// @schemes http
func main() {
// conf := config.GetConfig()
// database.ConnectMySqlDB(conf)
// foodGroup := models.FoodGroupMySql{
// Name: "mohammad",
// }
// r := mysql_database.NewFoodGroupMySqlRepository()
// r.Insert(foodGroup)
createServer()
}
func createServer() {
r := gin.Default()
r.MaxMultipartMemory = 4 << 20 // 4 MiB
r.Use(middleware.ValidationErrors)
r.GET("/", func(context *gin.Context) {
context.String(http.StatusOK, "Homepage")
})
r.Static("/Content", "./uploaded_file")
var rGroup = routes.ConfigAuth(r)
rGroupV1 := rGroup.Group("/v1")
routes.UserRouteV1(rGroupV1)
routes.FoodRouteV1(rGroupV1)
routes.FoodGroupRouteV1(rGroupV1)
rGroupV2 := rGroup.Group("/v2")
routes.FoodGroupRouteV2(rGroupV2)
routes.FoodRouteV2(rGroupV2)
routes.UserRouteV2(rGroupV2)
routes.ResturanRouteV2(rGroupV2)
url := ginSwagger.URL("http://localhost:8080/swagger/doc.json") // The url pointing to API definition
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url))
r.Run()
}