Moved http server to internal.
This commit is contained in:
parent
762f8e12c2
commit
d5aa919a37
@ -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())
|
||||
|
@ -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")
|
@ -1,4 +1,4 @@
|
||||
package server
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
Loading…
Reference in New Issue
Block a user