fix: Fixes API routes.

This commit is contained in:
Tera << 8 2024-12-23 20:47:01 -05:00
parent fe8980b265
commit bcf97fde6d
Signed by: imterah
GPG key ID: 8FA7DD57BA6CEA37
15 changed files with 284 additions and 132 deletions

View file

@ -106,33 +106,10 @@ func GetConnections(c *gin.Context) {
return
}
var backend dbcore.Backend
backendRequest := dbcore.DB.Where("id = ?", proxy.BackendID).First(&backend)
if backendRequest.Error != nil {
log.Warnf("failed to find backend: %s", backendRequest.Error)
c.JSON(http.StatusInternalServerError, gin.H{
"error": "Failed to find backend entry",
})
return
}
backendExists := backendRequest.RowsAffected > 0
if !backendExists {
c.JSON(http.StatusBadRequest, gin.H{
"error": "No forward entry found",
})
return
}
backendRuntime, ok := backendruntime.RunningBackends[backend.ID]
backendRuntime, ok := backendruntime.RunningBackends[proxy.BackendID]
if !ok {
log.Warnf("Couldn't fetch backend runtime from backend ID #%d", backend.ID)
log.Warnf("Couldn't fetch backend runtime from backend ID #%d", proxy.BackendID)
c.JSON(http.StatusInternalServerError, gin.H{
"error": "Couldn't fetch backend runtime",