Use the rove package ServerStatus type
This commit is contained in:
parent
a6d86c2581
commit
522e8205b3
2 changed files with 5 additions and 7 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/mdiluz/rove/pkg/rove"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewRouter() (router *mux.Router) {
|
func NewRouter() (router *mux.Router) {
|
||||||
|
@ -17,14 +18,9 @@ func NewRouter() (router *mux.Router) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// RouterStatus is a struct that contains information on the status of the server
|
|
||||||
type RouterStatus struct {
|
|
||||||
Ready bool `json:"ready"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// HandleStatus handles HTTP requests to the /status endpoint
|
// HandleStatus handles HTTP requests to the /status endpoint
|
||||||
func HandleStatus(w http.ResponseWriter, r *http.Request) {
|
func HandleStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
var status = RouterStatus{
|
var status = rove.ServerStatus{
|
||||||
Ready: true,
|
Ready: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/mdiluz/rove/pkg/rove"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestHandleStatus(t *testing.T) {
|
func TestHandleStatus(t *testing.T) {
|
||||||
|
@ -13,7 +15,7 @@ func TestHandleStatus(t *testing.T) {
|
||||||
|
|
||||||
HandleStatus(response, request)
|
HandleStatus(response, request)
|
||||||
|
|
||||||
var status RouterStatus
|
var status rove.ServerStatus
|
||||||
json.NewDecoder(response.Body).Decode(&status)
|
json.NewDecoder(response.Body).Decode(&status)
|
||||||
|
|
||||||
if status.Ready != true {
|
if status.Ready != true {
|
||||||
|
|
Loading…
Add table
Reference in a new issue