From f6b5684a5b157638ec5101b654e2e83aecb1a6fb Mon Sep 17 00:00:00 2001 From: PierreZ Date: Sun, 3 Jan 2016 20:42:09 +0100 Subject: [PATCH 1/2] adding read only mode --- web.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web.go b/web.go index 7605da19a..cf46392ab 100644 --- a/web.go +++ b/web.go @@ -19,6 +19,7 @@ import ( type WebProvider struct { Address string CertFile, KeyFile string + ReadOnly bool } 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/{provider}").HandlerFunc(getProviderHandler) 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) if vars["provider"] != "web" { response.WriteHeader(http.StatusBadRequest) From 6bcb6f92f5a1f61f0cfa5cbb274ce4e8090f6b71 Mon Sep 17 00:00:00 2001 From: Pierre Zemb Date: Sun, 3 Jan 2016 20:45:53 +0100 Subject: [PATCH 2/2] Update Doc about read-only mode --- docs/index.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/index.md b/docs/index.md index eca6c7ca4..573c552c3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -243,6 +243,11 @@ address = ":8080" # # CertFile = "traefik.crt" # KeyFile = "traefik.key" +# +# Set REST API to read-only mode +# +# Optional +# ReadOnly = false ``` - `/`: provides a simple HTML frontend of Træfik