Skip to content

Commit c7a8315

Browse files
committed
Update readme and remove comment code
1 parent ccc3517 commit c7a8315

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,20 @@ In setup router part in main.go, I used gin and group common api url. Some apis
5454
The authorize uses crypto functions to encrypt/decrypt claim data as specified of JSON WEB TOKEN - JWT. The apis using authentication middleware are create, update and delete product.
5555

5656
````go
57-
v1 := router.Group("/api/v1")
58-
{
59-
// Get products with params limit offset likes /products?limit=50&lastId=0
60-
v1.GET("/products", productHandler.GetProducts())
61-
v1.GET("/products/:productId", productHandler.GetSingleProduct())
62-
}
63-
v1.POST("/users/register", userHandler.Register())
64-
v1.POST("/users/login", userHandler.Login())
65-
v1.Use(api.Authorize())
66-
{
67-
v1.POST("/products", productHandler.CreateProduct())
68-
v1.PUT("/products", productHandler.UpdateProduct())
69-
v1.DELETE("/products/:productId", productHandler.DeleteProduct())
70-
}
57+
v1 := router.Group("/api/v1")
58+
{
59+
// Get products with params limit offset likes /products?limit=50&lastId=0
60+
v1.GET("/products", productHandler.GetProducts())
61+
v1.GET("/products/:productId", productHandler.GetSingleProduct())
62+
}
63+
v1.POST("/users/register", userHandler.Register())
64+
v1.POST("/users/login", userHandler.Login())
65+
v1.Use(api.Authorize())
66+
{
67+
v1.POST("/products", productHandler.CreateProduct())
68+
v1.PUT("/products", productHandler.UpdateProduct())
69+
v1.DELETE("/products/:productId", productHandler.DeleteProduct())
70+
}
7171
````
7272

7373
We have totally seven apis.

store/mysql_products.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@ import (
99
// Using lastId will has better performance. lastId is retrieved from previous page query.
1010
func (mysql *MySqlDB) GetProducts(limit, offset int, lastId int64) ([]*models.Product, error) {
1111

12-
// productsT := cache[lastId]
13-
// if productsT != nil && productsT.expire > time.Now().Unix() {
14-
// return productsT.products, nil
15-
// }
16-
//db := GetDB()
17-
// if db == nil {
18-
// return nil, errors.New("Can not connect to database")
19-
// }
20-
2112
query, err := mysql.DB.Query("SELECT * FROM products where product_id > ? ORDER BY product_id ASC limit ?", lastId, limit)
2213
if err != nil {
2314
return nil, models.NewError("Internal server error", ERR_INTERNAL)

0 commit comments

Comments
 (0)