File tree Expand file tree Collapse file tree 4 files changed +31
-7
lines changed
Expand file tree Collapse file tree 4 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -6,17 +6,17 @@ import (
66 "api-go/middleware"
77 "api-go/repository"
88 "api-go/usecase"
9-
109 "github.com/gin-gonic/gin"
1110)
1211
1312func main () {
14-
1513 server := gin .Default ()
1614
1715 dbConnection , err := db .ConnectDb ()
16+
1817 if err != nil {
1918 panic (err )
19+ return err
2020 }
2121
2222 ProductRepository := repository .NewProductRepository (dbConnection )
@@ -25,12 +25,17 @@ func main() {
2525
2626 ProductController := controller .NewProductController (* ProductUseCase )
2727
28- server .GET ("/ping" , func (ctx * gin.Context ) {
28+ server .GET ("/ping-dev " , func (ctx * gin.Context ) {
2929 ctx .JSON (200 , gin.H {
30- "message" : "primeiros testes " ,
30+ "message" : "Servidor Está ativo! " ,
3131 })
3232 })
3333
34+ /*
35+ routes server
36+ products
37+ */
38+
3439 protected := server .Group ("/" )
3540 protected .Use (middleware .AuthMiddleware ())
3641 {
Original file line number Diff line number Diff line change @@ -7,6 +7,21 @@ import (
77 _ "github.com/lib/pq"
88)
99
10+ /*
11+ configuration
12+ db
13+ */
14+
15+ /*
16+ var (
17+ host = "go_db" string
18+ port = 5432 int
19+ user = "postgres" string
20+ password = "1234" int
21+ dbname = "postgres"
22+
23+ )*/
24+
1025const (
1126 host = "go_db"
1227 port = 5432
@@ -29,7 +44,7 @@ func ConnectDb() (*sql.DB, error) {
2944 panic (err )
3045 }
3146
32- fmt .Println ("connected to" + dbname )
47+ // fmt.Println("connected to" + dbname)
3348
3449 return db , nil
3550}
Original file line number Diff line number Diff line change 11package model
22
3+ /*
4+ Product Struct
5+ */
6+
37type Product struct {
48 ID int `json:"id"`
59 Name string `json:"name"`
610 Price float64 `json:"price"`
7- }
11+ }
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ func (pr *ProductRepository) DeleteProduct(id int) error {
122122
123123 _ , err = query .Exec (id )
124124 if err != nil {
125- fmt .Println (err )
125+ // fmt.Println(err)
126126 return err
127127 }
128128
You can’t perform that action at this time.
0 commit comments