rove/cmd/rove-server/router.go

32 lines
583 B
Go
Raw Normal View History

package main
import (
"encoding/json"
2020-05-30 23:18:05 +01:00
"fmt"
"net/http"
"github.com/gorilla/mux"
2020-05-29 23:05:37 +01:00
"github.com/mdiluz/rove/pkg/rove"
)
2020-05-30 23:17:59 +01:00
// NewRouter sets up the server mux
func NewRouter() (router *mux.Router) {
router = mux.NewRouter().StrictSlash(true)
// Set up the handlers
router.HandleFunc("/status", HandleStatus)
return
}
// HandleStatus handles HTTP requests to the /status endpoint
func HandleStatus(w http.ResponseWriter, r *http.Request) {
2020-05-30 23:18:05 +01:00
fmt.Printf("%s\t%s", r.Method, r.RequestURI)
2020-05-29 23:05:37 +01:00
var status = rove.ServerStatus{
Ready: true,
}
json.NewEncoder(w).Encode(status)
}