mirror of
https://github.com/rclone/rclone.git
synced 2025-08-14 07:49:00 +02:00
serve http command to serve a remote over HTTP
This implements a basic webserver to serve an rclone remote over HTTP. It also sets up the framework for adding more types of server later.
This commit is contained in:
33
cmd/serve/serve.go
Normal file
33
cmd/serve/serve.go
Normal file
@ -0,0 +1,33 @@
|
||||
package serve
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/ncw/rclone/cmd"
|
||||
"github.com/ncw/rclone/cmd/serve/http"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Command.AddCommand(http.Command)
|
||||
cmd.Root.AddCommand(Command)
|
||||
}
|
||||
|
||||
// Command definition for cobra
|
||||
var Command = &cobra.Command{
|
||||
Use: "serve <protocol> [opts] <remote>",
|
||||
Short: `Serve a remote over a protocol.`,
|
||||
Long: `rclone serve is used to serve a remote over a given protocol. This
|
||||
command requires the use of a subcommand to specify the protocol, eg
|
||||
|
||||
rclone serve http remote:
|
||||
|
||||
Each subcommand has its own options which you can see in their help.
|
||||
`,
|
||||
RunE: func(command *cobra.Command, args []string) error {
|
||||
if len(args) == 0 {
|
||||
return errors.New("serve requires a protocol, eg 'rclone serve http remote:'")
|
||||
}
|
||||
return errors.New("unknown protocol")
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user