Documentation ¶
Index ¶
- Constants
- func AuthenticationMiddleware(next http.HandlerFunc) http.HandlerFunc
- func NewRouter() *mux.Router
- type Controller
- func (c *Controller) AddProduct(w http.ResponseWriter, r *http.Request)
- func (c *Controller) DeleteProduct(w http.ResponseWriter, r *http.Request)
- func (c *Controller) GetProduct(w http.ResponseWriter, r *http.Request)
- func (c *Controller) GetToken(w http.ResponseWriter, req *http.Request)
- func (c *Controller) Index(w http.ResponseWriter, r *http.Request)
- func (c *Controller) SearchProduct(w http.ResponseWriter, r *http.Request)
- func (c *Controller) UpdateProduct(w http.ResponseWriter, r *http.Request)
- type Exception
- type JwtToken
- type Product
- type Products
- type Repository
- func (r Repository) AddProduct(product Product) bool
- func (r Repository) DeleteProduct(id int) string
- func (r Repository) GetProductById(id int) Product
- func (r Repository) GetProducts() Products
- func (r Repository) GetProductsByString(query string) Products
- func (r Repository) UpdateProduct(product Product) bool
- type Route
- type Routes
- type User
Constants ¶
View Source
const COLLECTION = "store"
COLLECTION is the name of the collection in DB
View Source
const DBNAME = "dummyStore"
DBNAME the name of the DB instance
View Source
const SERVER = "mongodb://gautam:gautam@ds157233.mlab.com:57233/dummystore"
SERVER the DB server
Variables ¶
This section is empty.
Functions ¶
func AuthenticationMiddleware ¶
func AuthenticationMiddleware(next http.HandlerFunc) http.HandlerFunc
Middleware handler to handle all requests for authentication
Types ¶
type Controller ¶
type Controller struct {
Repository Repository
}
Controller ...
func (*Controller) AddProduct ¶
func (c *Controller) AddProduct(w http.ResponseWriter, r *http.Request)
AddProduct POST /
func (*Controller) DeleteProduct ¶
func (c *Controller) DeleteProduct(w http.ResponseWriter, r *http.Request)
DeleteProduct DELETE /
func (*Controller) GetProduct ¶
func (c *Controller) GetProduct(w http.ResponseWriter, r *http.Request)
GetProduct GET - Gets a single product by ID /
func (*Controller) GetToken ¶
func (c *Controller) GetToken(w http.ResponseWriter, req *http.Request)
Get Authentication token GET /
func (*Controller) Index ¶
func (c *Controller) Index(w http.ResponseWriter, r *http.Request)
Index GET /
func (*Controller) SearchProduct ¶
func (c *Controller) SearchProduct(w http.ResponseWriter, r *http.Request)
SearchProduct GET /
func (*Controller) UpdateProduct ¶
func (c *Controller) UpdateProduct(w http.ResponseWriter, r *http.Request)
UpdateProduct PUT /
type Product ¶
type Product struct { ID int `bson:"_id"` Title string `json:"title"` Image string `json:"image"` Price uint64 `json:"price"` Rating uint8 `json:"rating"` }
Product represents an e-comm item
type Repository ¶
type Repository struct{}
Repository ...
func (Repository) AddProduct ¶
func (r Repository) AddProduct(product Product) bool
AddProduct adds a Product in the DB
func (Repository) DeleteProduct ¶
func (r Repository) DeleteProduct(id int) string
DeleteProduct deletes an Product
func (Repository) GetProductById ¶
func (r Repository) GetProductById(id int) Product
GetProductById returns a unique Product
func (Repository) GetProducts ¶
func (r Repository) GetProducts() Products
GetProducts returns the list of Products
func (Repository) GetProductsByString ¶
func (r Repository) GetProductsByString(query string) Products
GetProductsByString takes a search string as input and returns products
func (Repository) UpdateProduct ¶
func (r Repository) UpdateProduct(product Product) bool
UpdateProduct updates a Product in the DB
Click to show internal directories.
Click to hide internal directories.