mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-03 07:01:35 -06:00
fmt.
This commit is contained in:
@@ -68,16 +68,16 @@ func (manager *ApiManagerCtx) roomRemove(w http.ResponseWriter, r *http.Request)
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func (manager *ApiManagerCtx) roomGenericAction(action func(id string) error) (func(http.ResponseWriter, *http.Request)) {
|
||||
func (manager *ApiManagerCtx) roomGenericAction(action func(id string) error) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
roomId := chi.URLParam(r, "roomId")
|
||||
|
||||
|
||||
err := action(roomId)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,12 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
dockerTypes "github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
|
||||
"m1k1o/neko_rooms/internal/types"
|
||||
)
|
||||
|
||||
|
||||
func (manager *RoomManagerCtx) containerToEntry(container dockerTypes.Container) (*types.RoomEntry, error) {
|
||||
roomName, ok := container.Labels["m1k1o.neko_rooms.name"]
|
||||
if !ok {
|
||||
@@ -46,7 +45,7 @@ func (manager *RoomManagerCtx) listContainers() ([]dockerTypes.Container, error)
|
||||
)
|
||||
|
||||
containers, err := manager.client.ContainerList(context.Background(), dockerTypes.ContainerListOptions{
|
||||
All: true,
|
||||
All: true,
|
||||
Filters: args,
|
||||
})
|
||||
|
||||
@@ -74,7 +73,7 @@ func (manager *RoomManagerCtx) containerInfo(id string) (*dockerTypes.Container,
|
||||
)
|
||||
|
||||
containers, err := manager.client.ContainerList(context.Background(), dockerTypes.ContainerListOptions{
|
||||
All: true,
|
||||
All: true,
|
||||
Filters: args,
|
||||
})
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
frontendPort = 8080
|
||||
frontendPort = 8080
|
||||
)
|
||||
|
||||
func New(config *config.Room) *RoomManagerCtx {
|
||||
@@ -57,7 +57,7 @@ func (manager *RoomManagerCtx) List() ([]types.RoomEntry, error) {
|
||||
entry, err := manager.containerToEntry(container)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
result = append(result, *entry)
|
||||
}
|
||||
@@ -266,7 +266,6 @@ func (manager *RoomManagerCtx) Start(id string) error {
|
||||
return manager.client.ContainerStart(context.Background(), id, dockerTypes.ContainerStartOptions{})
|
||||
}
|
||||
|
||||
|
||||
func (manager *RoomManagerCtx) Stop(id string) error {
|
||||
_, err := manager.inspectContainer(id)
|
||||
if err != nil {
|
||||
|
||||
@@ -2,8 +2,8 @@ package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user