mirror of
https://github.com/openziti/zrok.git
synced 2025-06-03 08:35:53 +02:00
webBackend -> proxy.WebBackend (#170)
This commit is contained in:
parent
56bb9c6d31
commit
e432dfdb28
@ -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")
|
||||
}
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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 }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user