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

View File

@ -1,7 +1,6 @@
package handlers
package http
import (
"dwelling-files/internal/server"
"dwelling-files/pkg/files"
"dwelling-files/pkg/utils"
"dwelling-files/web"
@ -38,7 +37,7 @@ func (FilesHandlers) AssetsFS() http.FileSystem {
}
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") {
h.assetsServer.ServeHTTP(w, r)

View File

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