build: refactor makefile

This commit is contained in:
Oleg Lobanov
2021-12-20 23:16:35 +01:00
parent b1e0d5b39f
commit f81857acce
15 changed files with 3333 additions and 87 deletions

View File

@@ -64,15 +64,16 @@ func handle(fn handleFunc, prefix string, store *storage.Storage, server *settin
server: server,
})
if status != 0 {
txt := http.StatusText(status)
http.Error(w, strconv.Itoa(status)+" "+txt, status)
}
if status >= 400 || err != nil {
clientIP := realip.FromRequest(r)
log.Printf("%s: %v %s %v", r.URL.Path, status, clientIP, err)
}
if status != 0 {
txt := http.StatusText(status)
http.Error(w, strconv.Itoa(status)+" "+txt, status)
return
}
})
return stripPrefix(prefix, handler)

View File

@@ -110,7 +110,7 @@ func TestPublicShareHandlerAuthentication(t *testing.T) {
func newHTTPRequest(t *testing.T, requestModifiers ...func(*http.Request)) *http.Request {
t.Helper()
r, err := http.NewRequest(http.MethodGet, "h", nil)
r, err := http.NewRequest(http.MethodGet, "h", http.NoBody)
if err != nil {
t.Fatalf("failed to construct request: %v", err)
}