mirror of
https://github.com/henrygd/beszel.git
synced 2025-12-17 02:36:17 +01:00
smart support over ssh + change response code for smart failure
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
|||||||
|
|
||||||
"github.com/henrygd/beszel"
|
"github.com/henrygd/beszel"
|
||||||
"github.com/henrygd/beszel/internal/common"
|
"github.com/henrygd/beszel/internal/common"
|
||||||
|
"github.com/henrygd/beszel/internal/entities/smart"
|
||||||
"github.com/henrygd/beszel/internal/entities/system"
|
"github.com/henrygd/beszel/internal/entities/system"
|
||||||
|
|
||||||
"github.com/blang/semver"
|
"github.com/blang/semver"
|
||||||
@@ -170,6 +171,8 @@ func (a *Agent) handleSSHRequest(w io.Writer, req *common.HubRequest[cbor.RawMes
|
|||||||
response.SystemData = v
|
response.SystemData = v
|
||||||
case string:
|
case string:
|
||||||
response.String = &v
|
response.String = &v
|
||||||
|
case map[string]smart.SmartData:
|
||||||
|
response.SmartData = v
|
||||||
default:
|
default:
|
||||||
response.Error = fmt.Sprintf("unsupported response type: %T", data)
|
response.Error = fmt.Sprintf("unsupported response type: %T", data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ func (h *Hub) containerRequestHandler(e *core.RequestEvent, fetchFunc func(*syst
|
|||||||
|
|
||||||
data, err := fetchFunc(system, containerID)
|
data, err := fetchFunc(system, containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return e.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
return e.JSON(http.StatusNotFound, map[string]string{"error": err.Error()})
|
||||||
}
|
}
|
||||||
|
|
||||||
return e.JSON(http.StatusOK, map[string]string{responseKey: data})
|
return e.JSON(http.StatusOK, map[string]string{responseKey: data})
|
||||||
@@ -338,7 +338,7 @@ func (h *Hub) getSmartData(e *core.RequestEvent) error {
|
|||||||
}
|
}
|
||||||
data, err := system.FetchSmartDataFromAgent()
|
data, err := system.FetchSmartDataFromAgent()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return e.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
return e.JSON(http.StatusNotFound, map[string]string{"error": err.Error()})
|
||||||
}
|
}
|
||||||
e.Response.Header().Set("Cache-Control", "public, max-age=60")
|
e.Response.Header().Set("Cache-Control", "public, max-age=60")
|
||||||
return e.JSON(http.StatusOK, data)
|
return e.JSON(http.StatusOK, data)
|
||||||
|
|||||||
Reference in New Issue
Block a user