In dwelling-upload's main changed aliases for imports.
This commit is contained in:
parent
532e8d9da6
commit
271c27f4ad
@ -1,19 +1,17 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"dwelling-upload/internal/http"
|
duihttp "dwelling-upload/internal/http"
|
||||||
"dwelling-upload/pkg/utils"
|
"dwelling-upload/pkg/utils"
|
||||||
"dwelling-upload/pkg/watcher"
|
"dwelling-upload/pkg/watcher"
|
||||||
"dwelling-upload/web"
|
"dwelling-upload/web"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
nethttp "net/http"
|
"net/http"
|
||||||
"net/netip"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"git.arav.su/Arav/httpr"
|
"git.arav.su/Arav/httpr"
|
||||||
@ -73,26 +71,26 @@ func main() {
|
|||||||
log.Fatalf("failed to get initial size of %s: %s", *uploadDir, err)
|
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)
|
*expiry, *storageSize, *fileSize)
|
||||||
|
|
||||||
r := httpr.New()
|
r := httpr.New()
|
||||||
|
|
||||||
r.NotFoundHandler = func(w nethttp.ResponseWriter, r *nethttp.Request) {
|
r.NotFoundHandler = func(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, r, nethttp.StatusNotFound, "")
|
duihttp.Error(w, r, http.StatusNotFound, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Handler(nethttp.MethodGet, "/", hand.Index)
|
r.Handler(http.MethodGet, "/", hand.Index)
|
||||||
r.Handler(nethttp.MethodPost, "/", hand.Upload)
|
r.Handler(http.MethodPost, "/", hand.Upload)
|
||||||
r.Handler(nethttp.MethodGet, "/:hash/:name", hand.Download)
|
r.Handler(http.MethodGet, "/:hash/:name", hand.Download)
|
||||||
r.Handler(nethttp.MethodPost, "/delete", hand.Delete)
|
r.Handler(http.MethodPost, "/delete", hand.Delete)
|
||||||
r.Handler(nethttp.MethodDelete, "/:hash", hand.Delete)
|
r.Handler(http.MethodDelete, "/:hash", hand.Delete)
|
||||||
|
|
||||||
r.ServeStatic("/assets/*filepath", web.Assets())
|
r.ServeStatic("/assets/*filepath", web.Assets())
|
||||||
r.Handler(nethttp.MethodGet, "/robots.txt", http.RobotsTxt)
|
r.Handler(http.MethodGet, "/robots.txt", duihttp.RobotsTxt)
|
||||||
r.Handler(nethttp.MethodGet, "/favicon.svg", http.Favicon)
|
r.Handler(http.MethodGet, "/favicon.svg", duihttp.Favicon)
|
||||||
|
|
||||||
srv := http.NewHttpServer(r)
|
srv := duihttp.NewHttpServer(r)
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := srv.Stop(); err != nil {
|
if err := srv.Stop(); err != nil {
|
||||||
log.Fatalln("failed to properly shutdown a server:", err)
|
log.Fatalln("failed to properly shutdown a server:", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user