package containers

import (
	"floares/lib/http/containers"
	"github.com/gin-gonic/gin"
)

func ListContainers(c *gin.Context) {
	container := containers.List()
	c.JSON(200, gin.H{
		"data": container,
	})
}

func CreateContainer(c *gin.Context) {
	var create containers.Create
	if err := c.BindJSON(&create); err != nil {
		c.JSON(200, gin.H{
			"data":  nil,
			"error": err.Error(),
		})
		return
	}
	id, err := create.Create()
	if err != nil {
		c.JSON(200, gin.H{
			"data":  nil,
			"error": err.Error(),
		})
		return
	}
	c.JSON(200, gin.H{
		"data": id,
	})
}
