mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 07:33:21 +00:00
Address linter issues
This commit is contained in:
parent
4e36854cd4
commit
ba9ee5c625
2 changed files with 20 additions and 19 deletions
6
mux.go
6
mux.go
|
@ -12,10 +12,6 @@ import (
|
||||||
"github.com/restic/rest-server/quota"
|
"github.com/restic/rest-server/quota"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
GiB = 1024 * 1024 * 1024
|
|
||||||
)
|
|
||||||
|
|
||||||
func (s *Server) debugHandler(next http.Handler) http.Handler {
|
func (s *Server) debugHandler(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(
|
return http.HandlerFunc(
|
||||||
func(w http.ResponseWriter, r *http.Request) {
|
func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -70,6 +66,8 @@ func NewHandler(server *Server) (http.Handler, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GiB = 1024 * 1024 * 1024
|
||||||
|
|
||||||
if server.MaxRepoSize > 0 {
|
if server.MaxRepoSize > 0 {
|
||||||
log.Printf("Initializing quota (can take a while)...")
|
log.Printf("Initializing quota (can take a while)...")
|
||||||
qm, err := quota.New(server.Path, server.MaxRepoSize)
|
qm, err := quota.New(server.Path, server.MaxRepoSize)
|
||||||
|
|
33
repo/repo.go
33
repo/repo.go
|
@ -93,9 +93,10 @@ func isHashed(objectType string) bool {
|
||||||
return objectType == "data"
|
return objectType == "data"
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlobOperation describe the current blob operation in the BlobMetricFunc callback
|
// BlobOperation describe the current blob operation in the BlobMetricFunc callback.
|
||||||
type BlobOperation byte
|
type BlobOperation byte
|
||||||
|
|
||||||
|
// Define all valid operations.
|
||||||
const (
|
const (
|
||||||
BlobRead = 'R' // A blob has been read
|
BlobRead = 'R' // A blob has been read
|
||||||
BlobWrite = 'W' // A blob has been written
|
BlobWrite = 'W' // A blob has been written
|
||||||
|
@ -146,22 +147,24 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
default:
|
default:
|
||||||
httpMethodNotAllowed(w, []string{"GET"})
|
httpMethodNotAllowed(w, []string{"GET"})
|
||||||
}
|
}
|
||||||
return
|
|
||||||
} else {
|
|
||||||
switch r.Method {
|
|
||||||
case "HEAD":
|
|
||||||
h.checkBlob(w, r)
|
|
||||||
case "GET":
|
|
||||||
h.getBlob(w, r)
|
|
||||||
case "POST":
|
|
||||||
h.saveBlob(w, r)
|
|
||||||
case "DELETE":
|
|
||||||
h.deleteBlob(w, r)
|
|
||||||
default:
|
|
||||||
httpMethodNotAllowed(w, []string{"HEAD", "GET", "POST", "DELETE"})
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch r.Method {
|
||||||
|
case "HEAD":
|
||||||
|
h.checkBlob(w, r)
|
||||||
|
case "GET":
|
||||||
|
h.getBlob(w, r)
|
||||||
|
case "POST":
|
||||||
|
h.saveBlob(w, r)
|
||||||
|
case "DELETE":
|
||||||
|
h.deleteBlob(w, r)
|
||||||
|
default:
|
||||||
|
httpMethodNotAllowed(w, []string{"HEAD", "GET", "POST", "DELETE"})
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
httpDefaultError(w, http.StatusNotFound)
|
httpDefaultError(w, http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue