Skip to content

Commit

Permalink
chore: update code styles for upstream.go
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJacky committed Dec 15, 2023
1 parent 9a18005 commit a63e85a
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions api/upstream/upstream.go
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
package upstream

import (
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/internal/upstream"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"net/http"
"time"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/internal/upstream"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"net/http"
"time"
)

func AvailabilityTest(c *gin.Context) {
var upGrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}
// upgrade http to websocket
ws, err := upGrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
logger.Error(err)
return
}

defer ws.Close()

var body []string

err = ws.ReadJSON(&body)

if err != nil {
logger.Error(err)
return
}

for {
err = ws.WriteJSON(upstream.AvailabilityTest(body))

if err != nil || websocket.IsUnexpectedCloseError(err,
websocket.CloseGoingAway,
websocket.CloseNoStatusReceived,
websocket.CloseNormalClosure) {
logger.Error(err)
break
}

time.Sleep(10 * time.Second)
}
var upGrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}
// upgrade http to websocket
ws, err := upGrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
logger.Error(err)
return
}

defer ws.Close()

var body []string

err = ws.ReadJSON(&body)

if err != nil {
logger.Error(err)
return
}

for {
err = ws.WriteJSON(upstream.AvailabilityTest(body))

if err != nil || websocket.IsUnexpectedCloseError(err,
websocket.CloseGoingAway,
websocket.CloseNoStatusReceived,
websocket.CloseNormalClosure) {
logger.Error(err)
break
}

time.Sleep(10 * time.Second)
}
}

0 comments on commit a63e85a

Please sign in to comment.