mirror of
https://github.com/rclone/rclone.git
synced 2025-06-21 12:33:52 +02:00
serve http: convert options to new style
This commit is contained in:
parent
3c981e6c2c
commit
cebd588092
@ -20,6 +20,8 @@ import (
|
|||||||
"github.com/rclone/rclone/cmd/serve/proxy/proxyflags"
|
"github.com/rclone/rclone/cmd/serve/proxy/proxyflags"
|
||||||
"github.com/rclone/rclone/fs"
|
"github.com/rclone/rclone/fs"
|
||||||
"github.com/rclone/rclone/fs/accounting"
|
"github.com/rclone/rclone/fs/accounting"
|
||||||
|
"github.com/rclone/rclone/fs/config/configstruct"
|
||||||
|
"github.com/rclone/rclone/fs/config/flags"
|
||||||
libhttp "github.com/rclone/rclone/lib/http"
|
libhttp "github.com/rclone/rclone/lib/http"
|
||||||
"github.com/rclone/rclone/lib/http/serve"
|
"github.com/rclone/rclone/lib/http/serve"
|
||||||
"github.com/rclone/rclone/lib/systemd"
|
"github.com/rclone/rclone/lib/systemd"
|
||||||
@ -29,6 +31,12 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// OptionsInfo describes the Options in use
|
||||||
|
var OptionsInfo = fs.Options{}.
|
||||||
|
Add(libhttp.ConfigInfo).
|
||||||
|
Add(libhttp.AuthConfigInfo).
|
||||||
|
Add(libhttp.TemplateConfigInfo)
|
||||||
|
|
||||||
// Options required for http server
|
// Options required for http server
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Auth libhttp.AuthConfig
|
Auth libhttp.AuthConfig
|
||||||
@ -46,15 +54,17 @@ var DefaultOpt = Options{
|
|||||||
// Opt is options set by command line flags
|
// Opt is options set by command line flags
|
||||||
var Opt = DefaultOpt
|
var Opt = DefaultOpt
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
fs.RegisterGlobalOptions(fs.OptionsInfo{Name: "http", Opt: &Opt, Options: OptionsInfo})
|
||||||
|
}
|
||||||
|
|
||||||
// flagPrefix is the prefix used to uniquely identify command line flags.
|
// flagPrefix is the prefix used to uniquely identify command line flags.
|
||||||
// It is intentionally empty for this package.
|
// It is intentionally empty for this package.
|
||||||
const flagPrefix = ""
|
const flagPrefix = ""
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flagSet := Command.Flags()
|
flagSet := Command.Flags()
|
||||||
libhttp.AddAuthFlagsPrefix(flagSet, flagPrefix, &Opt.Auth)
|
flags.AddFlagsFromOptions(flagSet, "", OptionsInfo)
|
||||||
libhttp.AddHTTPFlagsPrefix(flagSet, flagPrefix, &Opt.HTTP)
|
|
||||||
libhttp.AddTemplateFlagsPrefix(flagSet, flagPrefix, &Opt.Template)
|
|
||||||
vfsflags.AddFlags(flagSet)
|
vfsflags.AddFlags(flagSet)
|
||||||
proxyflags.AddFlags(flagSet)
|
proxyflags.AddFlags(flagSet)
|
||||||
cmdserve.Command.AddCommand(Command)
|
cmdserve.Command.AddCommand(Command)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user