naise_pos/api/server.go
2023-03-08 15:22:57 +07:00

28 lines
551 B
Go

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)
router.POST("/purchase-products", server.createPurchase)
server.router = router
return server
}
func (server *Server) Start(address string) error {
return server.router.Run(address)
}