mirror of
https://github.com/openziti/zrok.git
synced 2025-03-14 23:48:22 +01:00
proxy -> http listen (#32)
This commit is contained in:
parent
bb55008451
commit
6fa4fc2973
40
cmd/zrok/httplisten.go
Normal file
40
cmd/zrok/httplisten.go
Normal file
@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/openziti-test-kitchen/zrok/endpoints/listen"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
httpCmd.AddCommand(newHttpListenCommand().cmd)
|
||||
}
|
||||
|
||||
type httpListenCommand struct {
|
||||
endpoint string
|
||||
cmd *cobra.Command
|
||||
}
|
||||
|
||||
func newHttpListenCommand() *httpListenCommand {
|
||||
cmd := &cobra.Command{
|
||||
Use: "listen <zitiIdentity>",
|
||||
Short: "Create an HTTP listener",
|
||||
Args: cobra.ExactArgs(1),
|
||||
}
|
||||
command := &httpListenCommand{cmd: cmd}
|
||||
cmd.Flags().StringVarP(&command.endpoint, "endpoint", "e", "0.0.0.0:10111", "Address for HTTP listening endpoint")
|
||||
cmd.Run = command.run
|
||||
return command
|
||||
}
|
||||
|
||||
func (self *httpListenCommand) run(_ *cobra.Command, args []string) {
|
||||
httpListener, err := listen.NewHTTP(&listen.Config{
|
||||
IdentityPath: args[0],
|
||||
Address: self.endpoint,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := httpListener.Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/openziti-test-kitchen/zrok/endpoints/listen"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(proxyCmd)
|
||||
}
|
||||
|
||||
var proxyCmd = &cobra.Command{
|
||||
Use: "proxy <configPath>",
|
||||
Short: "Start a zrok proxy",
|
||||
Run: func(_ *cobra.Command, args []string) {
|
||||
httpListener, err := listen.NewHTTP(&listen.Config{
|
||||
IdentityPath: args[0],
|
||||
Address: "0.0.0.0:10111",
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := httpListener.Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue
Block a user