Skip to content

Commit

Permalink
added ping endpoint with get method and changed http status on test r…
Browse files Browse the repository at this point in the history
…esult to ok
  • Loading branch information
parsa committed Sep 2, 2023
1 parent a057355 commit d7a289e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion foreignusage/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,17 @@ func initRouter() *gin.Engine {
r.Use(gin.Recovery())

r.POST("/test", testHandler)
r.GET("/ping", pingSelf)

return r
}

func pingSelf(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "pong",
})
}

type link struct {
ID int `json:"id"`
Link string `json:"link"`
Expand Down Expand Up @@ -96,7 +103,7 @@ func testHandler(c *gin.Context) {

if c.GetHeader("Authorization") == os.Getenv("auth") {
res := getTestResultsAsService(&r.Links, &r.Timeout, &r.UpperBoundPingLimit, &r.TestUrl, &ctx)
c.JSON(http.StatusBadRequest, responseLinks{Links: res})
c.JSON(http.StatusOK, responseLinks{Links: res})
done <- true

} else {
Expand Down

0 comments on commit d7a289e

Please sign in to comment.