mirror of
https://github.com/openziti/zrok.git
synced 2025-02-16 10:19:18 +01:00
more scaffolding
This commit is contained in:
parent
e6edeebf44
commit
50d37132a1
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/michaelquigley/pfxlog"
|
"github.com/michaelquigley/pfxlog"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/proxy"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"os"
|
"os"
|
||||||
@ -12,6 +13,7 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
pfxlog.GlobalInit(logrus.InfoLevel, pfxlog.DefaultOptions().SetTrimPrefix("github.com/openziti-test-kitchen/"))
|
pfxlog.GlobalInit(logrus.InfoLevel, pfxlog.DefaultOptions().SetTrimPrefix("github.com/openziti-test-kitchen/"))
|
||||||
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "enable verbose logging")
|
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "enable verbose logging")
|
||||||
|
rootCmd.AddCommand(proxyCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
@ -25,6 +27,16 @@ var rootCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
var verbose bool
|
var verbose bool
|
||||||
|
|
||||||
|
var proxyCmd = &cobra.Command{
|
||||||
|
Use: "proxy <configPath>",
|
||||||
|
Short: "Start a zrok proxy",
|
||||||
|
Run: func(_ *cobra.Command, args []string) {
|
||||||
|
if err := proxy.Run(&proxy.Config{Address: "0.0.0.0:10081"}); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
5
proxy/config.go
Normal file
5
proxy/config.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package proxy
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
Address string
|
||||||
|
}
|
16
proxy/proxy.go
Normal file
16
proxy/proxy.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package proxy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Run(cfg *Config) error {
|
||||||
|
return http.ListenAndServe(cfg.Address, &handler{})
|
||||||
|
}
|
||||||
|
|
||||||
|
type handler struct{}
|
||||||
|
|
||||||
|
func (self *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
fmt.Fprintf(w, "zrok")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user