finish work
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"floares/lib/http/network"
|
||||
"floares/lib/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -20,10 +23,37 @@ func Disconnect(c *gin.Context) {
|
||||
"err": "",
|
||||
})
|
||||
}
|
||||
|
||||
func Connect(c *gin.Context) {
|
||||
ns := c.Param("ns")
|
||||
id := c.Query("id")
|
||||
err := network.Connect(ns, id)
|
||||
var req model.ConnectRequest
|
||||
json.NewDecoder(c.Request.Body).Decode(&req)
|
||||
err := network.Connect(ns, req)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"err": "",
|
||||
})
|
||||
}
|
||||
func ConnectALl(c *gin.Context) {
|
||||
type Containers struct {
|
||||
Name string `json:"name"`
|
||||
Id []string `json:"id"`
|
||||
}
|
||||
var id Containers
|
||||
err := json.NewDecoder(c.Request.Body).Decode(&id)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
err = network.MakerNet(id.Name, id.Id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"error": err.Error(),
|
||||
|
||||
Reference in New Issue
Block a user