HTTP server was reorganised in internal/http.
This commit is contained in:
parent
3d8ee35053
commit
bdcdecb612
@ -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)
|
||||||
|
|
||||||
|
@ -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)
|
@ -1,4 +1,4 @@
|
|||||||
package server
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
Loading…
Reference in New Issue
Block a user