Files
ocis/pkg/command/proxy.go
T

43 lines
1.0 KiB
Go
Raw Normal View History

2020-06-04 12:27:40 +02:00
// +build !simple
2020-03-11 19:29:37 +01:00
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis-proxy/pkg/command"
svcconfig "github.com/owncloud/ocis-proxy/pkg/config"
"github.com/owncloud/ocis-proxy/pkg/flagset"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/register"
)
// ProxyCommand is the entry point for the proxy command.
func ProxyCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "proxy",
Usage: "Start proxy server",
Category: "Extensions",
Flags: flagset.ServerWithConfig(cfg.Proxy),
2020-03-17 15:01:09 +01:00
Action: func(ctx *cli.Context) error {
proxyCommand := command.Server(configureProxy(cfg))
2020-03-11 19:29:37 +01:00
2020-03-17 15:01:09 +01:00
if err := proxyCommand.Before(ctx); err != nil {
2020-03-11 19:29:37 +01:00
return err
}
2020-03-17 15:01:09 +01:00
return cli.HandleAction(proxyCommand.Action, ctx)
2020-03-11 19:29:37 +01:00
},
}
}
func configureProxy(cfg *config.Config) *svcconfig.Config {
cfg.Proxy.Log.Level = cfg.Log.Level
cfg.Proxy.Log.Pretty = cfg.Log.Pretty
cfg.Proxy.Log.Color = cfg.Log.Color
return cfg.Proxy
}
func init() {
register.AddCommand(ProxyCommand)
}