mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
api: log api error
This commit is contained in:
parent
c166b12515
commit
6220d02f32
2 changed files with 10 additions and 2 deletions
|
@ -30,7 +30,7 @@ func (d *dockerInfo) MarshalJSON() ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DockerInfo(w http.ResponseWriter, r *http.Request) {
|
func DockerInfo(w http.ResponseWriter, r *http.Request) {
|
||||||
serveHTTP[dockerInfo, []dockerInfo](w, r, GetDockerInfo)
|
serveHTTP[dockerInfo](w, r, GetDockerInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDockerInfo(ctx context.Context, dockerClients DockerClients) ([]dockerInfo, gperr.Error) {
|
func GetDockerInfo(ctx context.Context, dockerClients DockerClients) ([]dockerInfo, gperr.Error) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/coder/websocket"
|
"github.com/coder/websocket"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/pkg/stdcopy"
|
"github.com/docker/docker/pkg/stdcopy"
|
||||||
|
"github.com/yusing/go-proxy/internal/logging"
|
||||||
"github.com/yusing/go-proxy/internal/net/gphttp"
|
"github.com/yusing/go-proxy/internal/net/gphttp"
|
||||||
"github.com/yusing/go-proxy/internal/net/gphttp/gpwebsocket"
|
"github.com/yusing/go-proxy/internal/net/gphttp/gpwebsocket"
|
||||||
"github.com/yusing/go-proxy/internal/utils/strutils"
|
"github.com/yusing/go-proxy/internal/utils/strutils"
|
||||||
|
@ -55,6 +56,13 @@ func Logs(w http.ResponseWriter, r *http.Request) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
writer := gpwebsocket.NewWriter(r.Context(), conn, websocket.MessageText)
|
writer := gpwebsocket.NewWriter(r.Context(), conn, websocket.MessageText)
|
||||||
stdcopy.StdCopy(writer, writer, logs) //de-multiplex logs
|
_, err = stdcopy.StdCopy(writer, writer, logs) // de-multiplex logs
|
||||||
|
if err != nil {
|
||||||
|
logging.Err(err).
|
||||||
|
Str("server", server).
|
||||||
|
Str("container", containerID).
|
||||||
|
Msg("failed to de-multiplex logs")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue