66 "github.com/gin-gonic/gin"
77 "github.com/gin-gonic/gin/binding"
88 "github.com/go-playground/validator/v10"
9- "github.com/naeemaei/golang-clean-web-api/api/middlewares "
10- "github.com/naeemaei/golang-clean-web-api/api/routers "
11- validation "github.com/naeemaei/golang-clean-web-api/api/validations "
9+ "github.com/naeemaei/golang-clean-web-api/api/middleware "
10+ "github.com/naeemaei/golang-clean-web-api/api/router "
11+ validation "github.com/naeemaei/golang-clean-web-api/api/validation "
1212 "github.com/naeemaei/golang-clean-web-api/config"
1313 "github.com/naeemaei/golang-clean-web-api/docs"
1414 "github.com/naeemaei/golang-clean-web-api/pkg/logging"
@@ -27,10 +27,10 @@ func InitServer(cfg *config.Config) {
2727 RegisterValidators ()
2828 RegisterPrometheus ()
2929
30- r .Use (middlewares .DefaultStructuredLogger (cfg ))
31- r .Use (middlewares .Cors (cfg ))
32- r .Use (middlewares .Prometheus ())
33- r .Use (gin .Logger (), gin .CustomRecovery (middlewares .ErrorHandler ) /*middlewares .TestMiddleware()*/ , middlewares .LimitByRequest ())
30+ r .Use (middleware .DefaultStructuredLogger (cfg ))
31+ r .Use (middleware .Cors (cfg ))
32+ r .Use (middleware .Prometheus ())
33+ r .Use (gin .Logger (), gin .CustomRecovery (middleware .ErrorHandler ) /*middleware .TestMiddleware()*/ , middleware .LimitByRequest ())
3434
3535 RegisterRoutes (r , cfg )
3636 RegisterSwagger (r , cfg )
@@ -49,63 +49,63 @@ func RegisterRoutes(r *gin.Engine, cfg *config.Config) {
4949 {
5050 // Test
5151 health := v1 .Group ("/health" )
52- testRouter := v1 .Group ("/test" /*middlewares .Authentication(cfg), middlewares .Authorization([]string{"admin"})*/ )
52+ testRouter := v1 .Group ("/test" /*middleware .Authentication(cfg), middleware .Authorization([]string{"admin"})*/ )
5353
5454 // User
5555 users := v1 .Group ("/users" )
5656
5757 // Base
58- countries := v1 .Group ("/countries" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
59- cities := v1 .Group ("/cities" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
60- files := v1 .Group ("/files" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
61- companies := v1 .Group ("/companies" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
62- colors := v1 .Group ("/colors" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
63- years := v1 .Group ("/years" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
58+ countries := v1 .Group ("/countries" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
59+ cities := v1 .Group ("/cities" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
60+ files := v1 .Group ("/files" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
61+ companies := v1 .Group ("/companies" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
62+ colors := v1 .Group ("/colors" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
63+ years := v1 .Group ("/years" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
6464
6565 // Property
66- properties := v1 .Group ("/properties" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
67- propertyCategories := v1 .Group ("/property-categories" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
66+ properties := v1 .Group ("/properties" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
67+ propertyCategories := v1 .Group ("/property-categories" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
6868
6969 // Car
70- carTypes := v1 .Group ("/car-types" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
71- gearboxes := v1 .Group ("/gearboxes" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
72- carModels := v1 .Group ("/car-models" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
73- carModelColors := v1 .Group ("/car-model-colors" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
74- carModelYears := v1 .Group ("/car-model-years" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
75- carModelPriceHistories := v1 .Group ("/car-model-price-histories" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
76- carModelImages := v1 .Group ("/car-model-images" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
77- carModelProperties := v1 .Group ("/car-model-properties" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" }))
78- carModelComments := v1 .Group ("/car-model-comments" , middlewares .Authentication (cfg ), middlewares .Authorization ([]string {"admin" , "default" }))
70+ carTypes := v1 .Group ("/car-types" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
71+ gearboxes := v1 .Group ("/gearboxes" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
72+ carModels := v1 .Group ("/car-models" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
73+ carModelColors := v1 .Group ("/car-model-colors" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
74+ carModelYears := v1 .Group ("/car-model-years" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
75+ carModelPriceHistories := v1 .Group ("/car-model-price-histories" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
76+ carModelImages := v1 .Group ("/car-model-images" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
77+ carModelProperties := v1 .Group ("/car-model-properties" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" }))
78+ carModelComments := v1 .Group ("/car-model-comments" , middleware .Authentication (cfg ), middleware .Authorization ([]string {"admin" , "default" }))
7979
8080 // Test
81- routers .Health (health )
82- routers .TestRouter (testRouter )
81+ router .Health (health )
82+ router .TestRouter (testRouter )
8383
8484 // User
85- routers .User (users , cfg )
85+ router .User (users , cfg )
8686
8787 // Base
88- routers .Country (countries , cfg )
89- routers .City (cities , cfg )
90- routers .File (files , cfg )
91- routers .Company (companies , cfg )
92- routers .Color (colors , cfg )
93- routers .Year (years , cfg )
88+ router .Country (countries , cfg )
89+ router .City (cities , cfg )
90+ router .File (files , cfg )
91+ router .Company (companies , cfg )
92+ router .Color (colors , cfg )
93+ router .Year (years , cfg )
9494
9595 // Property
96- routers .Property (properties , cfg )
97- routers .PropertyCategory (propertyCategories , cfg )
96+ router .Property (properties , cfg )
97+ router .PropertyCategory (propertyCategories , cfg )
9898
9999 // Car
100- routers .CarType (carTypes , cfg )
101- routers .Gearbox (gearboxes , cfg )
102- routers .CarModel (carModels , cfg )
103- routers .CarModelColor (carModelColors , cfg )
104- routers .CarModelYear (carModelYears , cfg )
105- routers .CarModelPriceHistory (carModelPriceHistories , cfg )
106- routers .CarModelImage (carModelImages , cfg )
107- routers .CarModelProperty (carModelProperties , cfg )
108- routers .CarModelComment (carModelComments , cfg )
100+ router .CarType (carTypes , cfg )
101+ router .Gearbox (gearboxes , cfg )
102+ router .CarModel (carModels , cfg )
103+ router .CarModelColor (carModelColors , cfg )
104+ router .CarModelYear (carModelYears , cfg )
105+ router .CarModelPriceHistory (carModelPriceHistories , cfg )
106+ router .CarModelImage (carModelImages , cfg )
107+ router .CarModelProperty (carModelProperties , cfg )
108+ router .CarModelComment (carModelComments , cfg )
109109
110110 r .Static ("/static" , "./uploads" )
111111
@@ -115,7 +115,7 @@ func RegisterRoutes(r *gin.Engine, cfg *config.Config) {
115115 v2 := api .Group ("/v2" )
116116 {
117117 health := v2 .Group ("/health" )
118- routers .Health (health )
118+ router .Health (health )
119119 }
120120}
121121
@@ -144,14 +144,14 @@ func RegisterSwagger(r *gin.Engine, cfg *config.Config) {
144144 r .GET ("/swagger/*any" , ginSwagger .WrapHandler (swaggerFiles .Handler ))
145145}
146146
147- func RegisterPrometheus (){
147+ func RegisterPrometheus () {
148148 err := prometheus .Register (metrics .DbCall )
149149 if err != nil {
150150 logger .Error (logging .Prometheus , logging .Startup , err .Error (), nil )
151151 }
152-
152+
153153 err = prometheus .Register (metrics .HttpDuration )
154154 if err != nil {
155155 logger .Error (logging .Prometheus , logging .Startup , err .Error (), nil )
156156 }
157- }
157+ }
0 commit comments