diff --git a/cmd/rest-server/main.go b/cmd/rest-server/main.go index 5b5a42b..7bf3fd7 100644 --- a/cmd/rest-server/main.go +++ b/cmd/rest-server/main.go @@ -2,14 +2,15 @@ package main import ( "errors" - restserver "github.com/restic/rest-server" - "github.com/spf13/cobra" "log" "net/http" "os" "path/filepath" "runtime" "runtime/pprof" + + restserver "github.com/restic/rest-server" + "github.com/spf13/cobra" ) // cmdRoot is the base command when no other command has been specified. diff --git a/cmd/rest-server/main_test.go b/cmd/rest-server/main_test.go index 5f41e92..b2a71e1 100644 --- a/cmd/rest-server/main_test.go +++ b/cmd/rest-server/main_test.go @@ -1,8 +1,9 @@ package main import ( - restserver "github.com/restic/rest-server" "testing" + + restserver "github.com/restic/rest-server" ) func TestTLSSettings(t *testing.T) { diff --git a/handlers.go b/handlers.go index 2f0e64e..f4d68ab 100644 --- a/handlers.go +++ b/handlers.go @@ -142,7 +142,7 @@ func CheckConfig(w http.ResponseWriter, r *http.Request) { } // private repos - if (Config.PrivateRepos && (getUser(r) != getRepo(r))) { + if Config.PrivateRepos && (getUser(r) != getRepo(r)) { http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) return } @@ -172,7 +172,7 @@ func GetConfig(w http.ResponseWriter, r *http.Request) { } // private repos - if (Config.PrivateRepos && (getUser(r) != getRepo(r))) { + if Config.PrivateRepos && (getUser(r) != getRepo(r)) { http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) return } @@ -202,7 +202,7 @@ func SaveConfig(w http.ResponseWriter, r *http.Request) { } // private repos - if (Config.PrivateRepos && (getUser(r) != getRepo(r))) { + if Config.PrivateRepos && (getUser(r) != getRepo(r)) { http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) return } @@ -238,7 +238,7 @@ func DeleteConfig(w http.ResponseWriter, r *http.Request) { } // private repos - if (Config.PrivateRepos && (getUser(r) != getRepo(r))) { + if Config.PrivateRepos && (getUser(r) != getRepo(r)) { http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) return } @@ -275,7 +275,7 @@ func ListBlobs(w http.ResponseWriter, r *http.Request) { } // private repos - if (Config.PrivateRepos && (getUser(r) != getRepo(r))) { + if Config.PrivateRepos && (getUser(r) != getRepo(r)) { http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) return } @@ -336,7 +336,7 @@ func CheckBlob(w http.ResponseWriter, r *http.Request) { } // private repos - if (Config.PrivateRepos && (getUser(r) != getRepo(r))) { + if Config.PrivateRepos && (getUser(r) != getRepo(r)) { http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) return } @@ -366,7 +366,7 @@ func GetBlob(w http.ResponseWriter, r *http.Request) { } // private repos - if (Config.PrivateRepos && (getUser(r) != getRepo(r))) { + if Config.PrivateRepos && (getUser(r) != getRepo(r)) { http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) return } @@ -408,7 +408,7 @@ func SaveBlob(w http.ResponseWriter, r *http.Request) { } // private repos - if (Config.PrivateRepos && (getUser(r) != getRepo(r))) { + if Config.PrivateRepos && (getUser(r) != getRepo(r)) { http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) return } @@ -483,12 +483,11 @@ func DeleteBlob(w http.ResponseWriter, r *http.Request) { } // private repos - if (Config.PrivateRepos && (getUser(r) != getRepo(r))) { + if Config.PrivateRepos && (getUser(r) != getRepo(r)) { http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) return } - if Config.AppendOnly && pat.Param(r, "type") != "locks" { http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) return @@ -534,12 +533,11 @@ func CreateRepo(w http.ResponseWriter, r *http.Request) { } // private repos - if (Config.PrivateRepos && (getUser(r) != getRepo(r))) { + if Config.PrivateRepos && (getUser(r) != getRepo(r)) { http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) return } - repo, err := join(Config.Path, getRepo(r)) if err != nil { http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) diff --git a/mux.go b/mux.go index 9ac3c65..ef529e9 100644 --- a/mux.go +++ b/mux.go @@ -14,17 +14,17 @@ import ( // Config struct holds program configuration. var Config = struct { - Path string - Listen string - Log string - CPUProfile string - TLSKey string - TLSCert string - TLS bool - AppendOnly bool + Path string + Listen string + Log string + CPUProfile string + TLS bool + TLSKey string + TLSCert string + AppendOnly bool PrivateRepos bool - Prometheus bool - Debug bool + Prometheus bool + Debug bool }{ Path: "/tmp/restic", Listen: ":8000",