1
0

HTTP server was reorganised in internal/http.

This commit is contained in:
Alexander Andreev 2023-01-12 04:58:54 +04:00
parent 3d8ee35053
commit bdcdecb612
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F
3 changed files with 6 additions and 8 deletions

View File

@ -1,8 +1,7 @@
package main package main
import ( import (
"dwelling-files/internal/handlers" "dwelling-files/internal/http"
"dwelling-files/internal/server"
"dwelling-files/web" "dwelling-files/web"
"flag" "flag"
"fmt" "fmt"
@ -47,8 +46,8 @@ func main() {
} }
} }
hand := handlers.New(directoryPath, web.Assets(), !*enableFileHandler) hand := http.New(directoryPath, web.Assets(), !*enableFileHandler)
srv := server.NewHttpServer() srv := http.NewHttpServer()
srv.GET("/*filepath", hand.Index) srv.GET("/*filepath", hand.Index)

View File

@ -1,7 +1,6 @@
package handlers package http
import ( import (
"dwelling-files/internal/server"
"dwelling-files/pkg/files" "dwelling-files/pkg/files"
"dwelling-files/pkg/utils" "dwelling-files/pkg/utils"
"dwelling-files/web" "dwelling-files/web"
@ -38,7 +37,7 @@ func (FilesHandlers) AssetsFS() http.FileSystem {
} }
func (h *FilesHandlers) Index(w http.ResponseWriter, r *http.Request) { func (h *FilesHandlers) Index(w http.ResponseWriter, r *http.Request) {
path := httprouter.CleanPath(server.GetURLParam(r, "filepath")) path := httprouter.CleanPath(GetURLParam(r, "filepath"))
if strings.HasPrefix(path, "/assets") { if strings.HasPrefix(path, "/assets") {
h.assetsServer.ServeHTTP(w, r) h.assetsServer.ServeHTTP(w, r)

View File

@ -1,4 +1,4 @@
package server package http
import ( import (
"context" "context"