Add a /ping endpoint

This endpoint can be used to check the service liveness. It can be used
for the kubernetes liveness and readiness probs.
This commit is contained in:
Peltoche
2019-01-03 14:57:20 +01:00
parent 053908c772
commit 8c7458812d
2 changed files with 21 additions and 0 deletions

View File

@@ -67,6 +67,7 @@ func setup() *echo.Echo {
return nil
}
})
e.GET("/ping", func(c echo.Context) error { return nil })
e.POST("/merge", merge)
g := e.Group("/convert")
g.POST("/html", convertHTML)

View File

@@ -0,0 +1,20 @@
package api
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/labstack/echo"
"github.com/stretchr/testify/assert"
)
func TestPing(t *testing.T) {
req := httptest.NewRequest(http.MethodGet, "/ping", nil)
rec := httptest.NewRecorder()
e := echo.New()
_ = e.NewContext(req, rec)
assert.Equal(t, http.StatusOK, rec.Code)
}