diff --git a/cmd/zrok/sharePrivate.go b/cmd/zrok/sharePrivate.go index cc7d1bdd..abe6e2d8 100644 --- a/cmd/zrok/sharePrivate.go +++ b/cmd/zrok/sharePrivate.go @@ -8,7 +8,6 @@ import ( "github.com/openziti/zrok/endpoints" "github.com/openziti/zrok/endpoints/proxy" "github.com/openziti/zrok/endpoints/tcpTunnel" - "github.com/openziti/zrok/endpoints/webBackend" "github.com/openziti/zrok/model" "github.com/openziti/zrok/rest_client_zrok" "github.com/openziti/zrok/rest_client_zrok/share" @@ -161,7 +160,7 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) { } case "web": - cfg := &webBackend.Config{ + cfg := &proxy.WebBackendConfig{ IdentityPath: zif, WebRoot: target, ShrToken: resp.Payload.ShrToken, @@ -241,8 +240,8 @@ func (cmd *sharePrivateCommand) proxyBackendMode(cfg *proxy.BackendConfig) (endp return be, nil } -func (cmd *sharePrivateCommand) webBackendMode(cfg *webBackend.Config) (endpoints.RequestHandler, error) { - be, err := webBackend.NewBackend(cfg) +func (cmd *sharePrivateCommand) webBackendMode(cfg *proxy.WebBackendConfig) (endpoints.RequestHandler, error) { + be, err := proxy.NewWebBackend(cfg) if err != nil { return nil, errors.Wrap(err, "error creating http web backend") } diff --git a/cmd/zrok/sharePublic.go b/cmd/zrok/sharePublic.go index b8f05548..336c51b7 100644 --- a/cmd/zrok/sharePublic.go +++ b/cmd/zrok/sharePublic.go @@ -7,7 +7,6 @@ import ( httptransport "github.com/go-openapi/runtime/client" "github.com/openziti/zrok/endpoints" "github.com/openziti/zrok/endpoints/proxy" - "github.com/openziti/zrok/endpoints/webBackend" "github.com/openziti/zrok/model" "github.com/openziti/zrok/rest_client_zrok" "github.com/openziti/zrok/rest_client_zrok/share" @@ -158,7 +157,7 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) { } case "web": - cfg := &webBackend.Config{ + cfg := &proxy.WebBackendConfig{ IdentityPath: zif, WebRoot: target, ShrToken: resp.Payload.ShrToken, @@ -224,8 +223,8 @@ func (cmd *sharePublicCommand) proxyBackendMode(cfg *proxy.BackendConfig) (endpo return be, nil } -func (cmd *sharePublicCommand) webBackendMode(cfg *webBackend.Config) (endpoints.RequestHandler, error) { - be, err := webBackend.NewBackend(cfg) +func (cmd *sharePublicCommand) webBackendMode(cfg *proxy.WebBackendConfig) (endpoints.RequestHandler, error) { + be, err := proxy.NewWebBackend(cfg) if err != nil { return nil, errors.Wrap(err, "error creating http web backend") } diff --git a/cmd/zrok/shareReserved.go b/cmd/zrok/shareReserved.go index 6f6d0a63..554580f9 100644 --- a/cmd/zrok/shareReserved.go +++ b/cmd/zrok/shareReserved.go @@ -6,7 +6,6 @@ import ( httptransport "github.com/go-openapi/runtime/client" "github.com/openziti/zrok/endpoints" "github.com/openziti/zrok/endpoints/proxy" - "github.com/openziti/zrok/endpoints/webBackend" "github.com/openziti/zrok/rest_client_zrok/metadata" "github.com/openziti/zrok/rest_client_zrok/share" "github.com/openziti/zrok/rest_model_zrok" @@ -124,7 +123,7 @@ func (cmd *shareReservedCommand) run(_ *cobra.Command, args []string) { } case "web": - cfg := &webBackend.Config{ + cfg := &proxy.WebBackendConfig{ IdentityPath: zif, WebRoot: target, ShrToken: shrToken, @@ -202,8 +201,8 @@ func (cmd *shareReservedCommand) proxyBackendMode(cfg *proxy.BackendConfig) (end return be, nil } -func (cmd *shareReservedCommand) webBackendMode(cfg *webBackend.Config) (endpoints.RequestHandler, error) { - be, err := webBackend.NewBackend(cfg) +func (cmd *shareReservedCommand) webBackendMode(cfg *proxy.WebBackendConfig) (endpoints.RequestHandler, error) { + be, err := proxy.NewWebBackend(cfg) if err != nil { return nil, errors.Wrap(err, "error creating http web backend") } diff --git a/endpoints/webBackend/web.go b/endpoints/proxy/webBackend.go similarity index 85% rename from endpoints/webBackend/web.go rename to endpoints/proxy/webBackend.go index 199af144..de4d24cc 100644 --- a/endpoints/webBackend/web.go +++ b/endpoints/proxy/webBackend.go @@ -1,4 +1,4 @@ -package webBackend +package proxy import ( "fmt" @@ -11,20 +11,20 @@ import ( "time" ) -type Config struct { +type WebBackendConfig struct { IdentityPath string WebRoot string ShrToken string RequestsChan chan *endpoints.Request } -type backend struct { - cfg *Config +type WebBackend struct { + cfg *WebBackendConfig listener edge.Listener handler http.Handler } -func NewBackend(cfg *Config) (*backend, error) { +func NewWebBackend(cfg *WebBackendConfig) (*WebBackend, error) { options := ziti.ListenOptions{ ConnectTimeout: 5 * time.Minute, MaxConnections: 64, @@ -38,7 +38,7 @@ func NewBackend(cfg *Config) (*backend, error) { return nil, errors.Wrap(err, "error listening") } - be := &backend{ + be := &WebBackend{ cfg: cfg, listener: listener, } @@ -50,14 +50,14 @@ func NewBackend(cfg *Config) (*backend, error) { return be, nil } -func (self *backend) Run() error { +func (self *WebBackend) Run() error { if err := http.Serve(self.listener, self.handler); err != nil { return err } return nil } -func (self *backend) Requests() func() int32 { +func (self *WebBackend) Requests() func() int32 { return func() int32 { return 0 } }