1
0
Fork 0

In dwelling-upload's main changed aliases for imports.

This commit is contained in:
Alexander Andreev 2023-08-06 01:28:55 +04:00
parent 532e8d9da6
commit 271c27f4ad
Signed by: Arav
GPG Key ID: D22A817D95815393
1 changed files with 13 additions and 15 deletions

View File

@ -1,19 +1,17 @@
package main
import (
"dwelling-upload/internal/http"
duihttp "dwelling-upload/internal/http"
"dwelling-upload/pkg/utils"
"dwelling-upload/pkg/watcher"
"dwelling-upload/web"
"flag"
"fmt"
"log"
nethttp "net/http"
"net/netip"
"net/http"
"os"
"os/signal"
"path"
"strings"
"syscall"
"git.arav.su/Arav/httpr"
@ -73,26 +71,26 @@ func main() {
log.Fatalf("failed to get initial size of %s: %s", *uploadDir, err)
}
hand := http.NewUploadHandlers(logFile, *uploadDir, &uploadDirSize, string(hashSalt),
hand := duihttp.NewUploadHandlers(logFile, *uploadDir, &uploadDirSize, string(hashSalt),
*expiry, *storageSize, *fileSize)
r := httpr.New()
r.NotFoundHandler = func(w nethttp.ResponseWriter, r *nethttp.Request) {
http.Error(w, r, nethttp.StatusNotFound, "")
r.NotFoundHandler = func(w http.ResponseWriter, r *http.Request) {
duihttp.Error(w, r, http.StatusNotFound, "")
}
r.Handler(nethttp.MethodGet, "/", hand.Index)
r.Handler(nethttp.MethodPost, "/", hand.Upload)
r.Handler(nethttp.MethodGet, "/:hash/:name", hand.Download)
r.Handler(nethttp.MethodPost, "/delete", hand.Delete)
r.Handler(nethttp.MethodDelete, "/:hash", hand.Delete)
r.Handler(http.MethodGet, "/", hand.Index)
r.Handler(http.MethodPost, "/", hand.Upload)
r.Handler(http.MethodGet, "/:hash/:name", hand.Download)
r.Handler(http.MethodPost, "/delete", hand.Delete)
r.Handler(http.MethodDelete, "/:hash", hand.Delete)
r.ServeStatic("/assets/*filepath", web.Assets())
r.Handler(nethttp.MethodGet, "/robots.txt", http.RobotsTxt)
r.Handler(nethttp.MethodGet, "/favicon.svg", http.Favicon)
r.Handler(http.MethodGet, "/robots.txt", duihttp.RobotsTxt)
r.Handler(http.MethodGet, "/favicon.svg", duihttp.Favicon)
srv := http.NewHttpServer(r)
srv := duihttp.NewHttpServer(r)
defer func() {
if err := srv.Stop(); err != nil {
log.Fatalln("failed to properly shutdown a server:", err)