From 002d323c9405d639d74fd7735ec6bc349f08b6fa Mon Sep 17 00:00:00 2001 From: Nolan Woods Date: Mon, 19 Apr 2021 21:50:08 -0700 Subject: [PATCH] lib/http: Move HTTP object serialization logic to lib/http --- cmd/serve/http/http.go | 2 +- cmd/serve/restic/restic.go | 2 +- cmd/serve/webdav/webdav.go | 2 +- fs/rc/rcserver/rcserver.go | 2 +- {cmd/serve/httplib => lib/http}/serve/dir.go | 0 {cmd/serve/httplib => lib/http}/serve/dir_test.go | 5 +++-- {cmd/serve/httplib => lib/http}/serve/serve.go | 0 {cmd/serve/httplib => lib/http}/serve/serve_test.go | 0 8 files changed, 7 insertions(+), 6 deletions(-) rename {cmd/serve/httplib => lib/http}/serve/dir.go (100%) rename {cmd/serve/httplib => lib/http}/serve/dir_test.go (96%) rename {cmd/serve/httplib => lib/http}/serve/serve.go (100%) rename {cmd/serve/httplib => lib/http}/serve/serve_test.go (100%) diff --git a/cmd/serve/http/http.go b/cmd/serve/http/http.go index aeef57e78..3d374e6ce 100644 --- a/cmd/serve/http/http.go +++ b/cmd/serve/http/http.go @@ -12,9 +12,9 @@ import ( "github.com/rclone/rclone/cmd" "github.com/rclone/rclone/cmd/serve/httplib" "github.com/rclone/rclone/cmd/serve/httplib/httpflags" - "github.com/rclone/rclone/cmd/serve/httplib/serve" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/accounting" + "github.com/rclone/rclone/lib/http/serve" "github.com/rclone/rclone/vfs" "github.com/rclone/rclone/vfs/vfsflags" "github.com/spf13/cobra" diff --git a/cmd/serve/restic/restic.go b/cmd/serve/restic/restic.go index ae218689f..e1bd75533 100644 --- a/cmd/serve/restic/restic.go +++ b/cmd/serve/restic/restic.go @@ -15,13 +15,13 @@ import ( "github.com/rclone/rclone/cmd" "github.com/rclone/rclone/cmd/serve/httplib" "github.com/rclone/rclone/cmd/serve/httplib/httpflags" - "github.com/rclone/rclone/cmd/serve/httplib/serve" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/accounting" "github.com/rclone/rclone/fs/config/flags" "github.com/rclone/rclone/fs/fserrors" "github.com/rclone/rclone/fs/operations" "github.com/rclone/rclone/fs/walk" + "github.com/rclone/rclone/lib/http/serve" "github.com/rclone/rclone/lib/terminal" "github.com/spf13/cobra" "golang.org/x/net/http2" diff --git a/cmd/serve/webdav/webdav.go b/cmd/serve/webdav/webdav.go index 049f1acf6..531842936 100644 --- a/cmd/serve/webdav/webdav.go +++ b/cmd/serve/webdav/webdav.go @@ -11,13 +11,13 @@ import ( "github.com/rclone/rclone/cmd" "github.com/rclone/rclone/cmd/serve/httplib" "github.com/rclone/rclone/cmd/serve/httplib/httpflags" - "github.com/rclone/rclone/cmd/serve/httplib/serve" "github.com/rclone/rclone/cmd/serve/proxy" "github.com/rclone/rclone/cmd/serve/proxy/proxyflags" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/config/flags" "github.com/rclone/rclone/fs/hash" "github.com/rclone/rclone/lib/errors" + "github.com/rclone/rclone/lib/http/serve" "github.com/rclone/rclone/vfs" "github.com/rclone/rclone/vfs/vfsflags" "github.com/spf13/cobra" diff --git a/fs/rc/rcserver/rcserver.go b/fs/rc/rcserver/rcserver.go index fe9aaacf5..cf2a6c126 100644 --- a/fs/rc/rcserver/rcserver.go +++ b/fs/rc/rcserver/rcserver.go @@ -26,7 +26,6 @@ import ( "github.com/skratchdot/open-golang/open" "github.com/rclone/rclone/cmd/serve/httplib" - "github.com/rclone/rclone/cmd/serve/httplib/serve" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/accounting" "github.com/rclone/rclone/fs/cache" @@ -35,6 +34,7 @@ import ( "github.com/rclone/rclone/fs/rc" "github.com/rclone/rclone/fs/rc/jobs" "github.com/rclone/rclone/fs/rc/rcflags" + "github.com/rclone/rclone/lib/http/serve" "github.com/rclone/rclone/lib/random" ) diff --git a/cmd/serve/httplib/serve/dir.go b/lib/http/serve/dir.go similarity index 100% rename from cmd/serve/httplib/serve/dir.go rename to lib/http/serve/dir.go diff --git a/cmd/serve/httplib/serve/dir_test.go b/lib/http/serve/dir_test.go similarity index 96% rename from cmd/serve/httplib/serve/dir_test.go rename to lib/http/serve/dir_test.go index 50d3e13bf..bdcf3f948 100644 --- a/cmd/serve/httplib/serve/dir_test.go +++ b/lib/http/serve/dir_test.go @@ -10,13 +10,14 @@ import ( "testing" "time" - "github.com/rclone/rclone/cmd/serve/httplib/serve/data" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/rclone/rclone/cmd/serve/http/data" ) func GetTemplate(t *testing.T) *template.Template { - htmlTemplate, err := data.GetTemplate("../../http/testdata/golden/testindex.html") + htmlTemplate, err := data.GetTemplate("../../../cmd/serve/http/testdata/golden/testindex.html") require.NoError(t, err) return htmlTemplate } diff --git a/cmd/serve/httplib/serve/serve.go b/lib/http/serve/serve.go similarity index 100% rename from cmd/serve/httplib/serve/serve.go rename to lib/http/serve/serve.go diff --git a/cmd/serve/httplib/serve/serve_test.go b/lib/http/serve/serve_test.go similarity index 100% rename from cmd/serve/httplib/serve/serve_test.go rename to lib/http/serve/serve_test.go