Add HTTP API
Add `-api` mode to start the HTTP API with the following routes: - /health - /shops - /shops/:id - /products - /products/:id Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
3122e59325
commit
17a88265c6
7 changed files with 200 additions and 3 deletions
|
|
@ -12,8 +12,8 @@ type Product struct {
|
|||
Price float64 `gorm:"not null" json:"price"`
|
||||
PriceCurrency string `gorm:"not null" json:"price_currency"`
|
||||
Available bool `gorm:"not null;default:false" json:"available"`
|
||||
ShopID uint
|
||||
Shop Shop
|
||||
ShopID uint `json:"shop_id"`
|
||||
Shop Shop `json:"shop"`
|
||||
}
|
||||
|
||||
// Equal compares a database product to another product
|
||||
|
|
@ -41,5 +41,5 @@ func (p *Product) ToMerge(o *Product) bool {
|
|||
// Shop represents a retailer website
|
||||
type Shop struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
Name string `gorm:"unique"`
|
||||
Name string `gorm:"unique" json:"name"`
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue