adding read only mode
This commit is contained in:
parent
866e8db5f7
commit
f6b5684a5b
1 changed files with 6 additions and 0 deletions
6
web.go
6
web.go
|
@ -19,6 +19,7 @@ import (
|
||||||
type WebProvider struct {
|
type WebProvider struct {
|
||||||
Address string
|
Address string
|
||||||
CertFile, KeyFile string
|
CertFile, KeyFile string
|
||||||
|
ReadOnly bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -40,6 +41,11 @@ func (provider *WebProvider) Provide(configurationChan chan<- types.ConfigMessag
|
||||||
systemRouter.Methods("GET").Path("/api/providers").HandlerFunc(getConfigHandler)
|
systemRouter.Methods("GET").Path("/api/providers").HandlerFunc(getConfigHandler)
|
||||||
systemRouter.Methods("GET").Path("/api/providers/{provider}").HandlerFunc(getProviderHandler)
|
systemRouter.Methods("GET").Path("/api/providers/{provider}").HandlerFunc(getProviderHandler)
|
||||||
systemRouter.Methods("PUT").Path("/api/providers/{provider}").HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
|
systemRouter.Methods("PUT").Path("/api/providers/{provider}").HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
|
||||||
|
if provider.ReadOnly {
|
||||||
|
response.WriteHeader(http.StatusForbidden)
|
||||||
|
fmt.Fprintf(response, "REST API is in read-only mode")
|
||||||
|
return
|
||||||
|
}
|
||||||
vars := mux.Vars(request)
|
vars := mux.Vars(request)
|
||||||
if vars["provider"] != "web" {
|
if vars["provider"] != "web" {
|
||||||
response.WriteHeader(http.StatusBadRequest)
|
response.WriteHeader(http.StatusBadRequest)
|
||||||
|
|
Loading…
Reference in a new issue