diff --git a/cmd/dwelling-upload/main.go b/cmd/dwelling-upload/main.go index 560a20a..53ab00b 100644 --- a/cmd/dwelling-upload/main.go +++ b/cmd/dwelling-upload/main.go @@ -2,9 +2,8 @@ package main import ( "dwelling-upload/internal/configuration" - "dwelling-upload/internal/handlers" + "dwelling-upload/internal/http" "dwelling-upload/pkg/logging" - "dwelling-upload/pkg/server" "dwelling-upload/pkg/utils" "dwelling-upload/pkg/watcher" "flag" @@ -81,8 +80,8 @@ func main() { watcha.WatchForMask(uploadDirNotify, watcher.CrDelMask) - hand := handlers.NewUploadHandlers(config, logErr, logUpload, logDownload, logDelete, &uploadDirSize) - srv := server.NewHttpServer() + hand := http.NewUploadHandlers(config, logErr, logUpload, logDownload, logDelete, &uploadDirSize) + srv := http.NewHttpServer() srv.SetNotFoundHandler(hand.NotFound) srv.ServeStatic("/assets/*filepath", hand.AssetsFS()) diff --git a/internal/handlers/handlers.go b/internal/http/handlers.go similarity index 97% rename from internal/handlers/handlers.go rename to internal/http/handlers.go index 16ad321..f3d37f9 100644 --- a/internal/handlers/handlers.go +++ b/internal/http/handlers.go @@ -1,10 +1,9 @@ -package handlers +package http import ( "crypto/sha256" "dwelling-upload/internal/configuration" "dwelling-upload/pkg/logging" - "dwelling-upload/pkg/server" "dwelling-upload/pkg/utils" "dwelling-upload/web" "encoding/base64" @@ -153,7 +152,7 @@ func (h *UploadHandlers) Upload(w http.ResponseWriter, r *http.Request) { } func (h *UploadHandlers) Download(w http.ResponseWriter, r *http.Request) { - saltedHash := server.GetURLParam(r, "hash") + saltedHash := GetURLParam(r, "hash") path := path.Join(h.conf.Uploads.Directory, saltedHash) @@ -163,7 +162,7 @@ func (h *UploadHandlers) Download(w http.ResponseWriter, r *http.Request) { return } - name := server.GetURLParam(r, "name") + name := GetURLParam(r, "name") w.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", name)) @@ -185,7 +184,7 @@ func (h *UploadHandlers) Download(w http.ResponseWriter, r *http.Request) { func (h *UploadHandlers) Delete(w http.ResponseWriter, r *http.Request) { var saltedHash string if r.Method == "DELETE" { - saltedHash = server.GetURLParam(r, "hash") + saltedHash = GetURLParam(r, "hash") } else { r.ParseForm() saltedHash = r.FormValue("hash") diff --git a/pkg/server/http.go b/internal/http/server.go similarity index 99% rename from pkg/server/http.go rename to internal/http/server.go index 2fb6c74..3212dce 100644 --- a/pkg/server/http.go +++ b/internal/http/server.go @@ -1,4 +1,4 @@ -package server +package http import ( "context"