Add endpoint for health checking the server (ping)
This commit is contained in:
parent
304eb928eb
commit
aebdb733a8
|
@ -98,12 +98,13 @@ func server() {
|
|||
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
r := gin.Default()
|
||||
r.GET("/", helloWorld)
|
||||
//r.GET("/", helloWorld)
|
||||
// TODO: Have fun creating new endpoints
|
||||
r.GET("/api/user", getUsers)
|
||||
r.GET("/api/user/:userid", getUser)
|
||||
r.POST("/api/user", createUser)
|
||||
r.DELETE("/api/user/:userid", deleteUser)
|
||||
r.GET("/api/ping", ping)
|
||||
|
||||
r.Run(":" + ListenPort)
|
||||
}
|
||||
|
@ -225,8 +226,6 @@ func getUsers(c *gin.Context) {
|
|||
c.IndentedJSON(http.StatusOK, setResponse(users, true))
|
||||
}
|
||||
|
||||
func helloWorld(c *gin.Context) {
|
||||
ua := c.Request.UserAgent()
|
||||
message := fmt.Sprintf("Hello %v!\n", ua)
|
||||
c.String(http.StatusOK, message)
|
||||
func ping(c *gin.Context) {
|
||||
c.IndentedJSON(http.StatusOK, setResponse("Pong!", true))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue