naise_pos/api/server.go

28 lines
551 B
Go
Raw Normal View History

2023-03-07 18:52:37 +07:00
package api
import (
db "git.nochill.in/nochill/naice_pos/db/sqlc"
"github.com/gin-gonic/gin"
)
type Server struct {
store *db.Store
router *gin.Engine
}
func NewServer(store *db.Store) *Server {
server := &Server{store: store}
router := gin.Default()
router.POST("/products", server.createProduct)
router.POST("/suppliers", server.createSupplier)
2023-03-08 15:22:57 +07:00
router.POST("/purchase-products", server.createPurchase)
2023-03-07 18:52:37 +07:00
server.router = router
return server
}
func (server *Server) Start(address string) error {
return server.router.Run(address)
}