27 lines
493 B
Go
27 lines
493 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)
|
||
|
|
||
|
server.router = router
|
||
|
return server
|
||
|
}
|
||
|
|
||
|
func (server *Server) Start(address string) error {
|
||
|
return server.router.Run(address)
|
||
|
}
|