Add /api/providers API
This commit is contained in:
parent
93b5410987
commit
0b3928dafb
2 changed files with 28 additions and 24 deletions
6
web.go
6
web.go
|
@ -6,6 +6,7 @@ import (
|
|||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/BurntSushi/ty/fun"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/elazarl/go-bindata-assetfs"
|
||||
"github.com/gorilla/mux"
|
||||
|
@ -25,6 +26,7 @@ func (provider *WebProvider) Provide(configurationChan chan<- configMessage) err
|
|||
systemRouter.Methods("GET").Path("/").Handler(http.HandlerFunc(GetHTMLConfigHandler))
|
||||
systemRouter.Methods("GET").Path("/health").Handler(http.HandlerFunc(GetHealthHandler))
|
||||
systemRouter.Methods("GET").Path("/api").Handler(http.HandlerFunc(GetConfigHandler))
|
||||
systemRouter.Methods("GET").Path("/api/providers").Handler(http.HandlerFunc(GetProvidersHandler))
|
||||
systemRouter.Methods("GET").Path("/api/{provider}").Handler(http.HandlerFunc(GetConfigHandler))
|
||||
systemRouter.Methods("PUT").Path("/api/{provider}").Handler(http.HandlerFunc(
|
||||
func(rw http.ResponseWriter, r *http.Request) {
|
||||
|
@ -82,6 +84,10 @@ func GetHealthHandler(rw http.ResponseWriter, r *http.Request) {
|
|||
templatesRenderer.JSON(rw, http.StatusOK, metrics.Data())
|
||||
}
|
||||
|
||||
func GetProvidersHandler(rw http.ResponseWriter, r *http.Request) {
|
||||
templatesRenderer.JSON(rw, http.StatusOK, fun.Keys(currentConfigurations))
|
||||
}
|
||||
|
||||
func GetBackendsHandler(rw http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
providerId := vars["provider"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue