mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 07:33:21 +00:00
Minor cleanup and fixes
- Do not allow '.' as path component, because it undermines depth checks, and add tests - Fix GiB reporting - Fix metrics label - Helper function for http errors
This commit is contained in:
parent
1f593fafaf
commit
d4cd47e503
5 changed files with 41 additions and 18 deletions
6
mux.go
6
mux.go
|
@ -12,6 +12,10 @@ import (
|
|||
"github.com/restic/rest-server/quota"
|
||||
)
|
||||
|
||||
const (
|
||||
GiB = 1024 * 1024 * 1024
|
||||
)
|
||||
|
||||
func (s *Server) debugHandler(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(
|
||||
func(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -58,7 +62,7 @@ func NewHandler(server *Server) (http.Handler, error) {
|
|||
return nil, err
|
||||
}
|
||||
server.quotaManager = qm
|
||||
log.Printf("Quota initialized, currenly using %.2f GiB", float64(qm.SpaceUsed()/1024/1024))
|
||||
log.Printf("Quota initialized, currenly using %.2f GiB", float64(qm.SpaceUsed())/GiB)
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue