mirror of
https://github.com/openziti/zrok.git
synced 2025-06-21 02:07:44 +02:00
re-enable 'zrok http' chrome
This commit is contained in:
parent
d87ec1257a
commit
e32bca31b2
125
cmd/zrok/http.go
125
cmd/zrok/http.go
@ -1,8 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
ui "github.com/gizak/termui/v3"
|
||||||
|
"github.com/gizak/termui/v3/widgets"
|
||||||
"github.com/go-openapi/runtime"
|
"github.com/go-openapi/runtime"
|
||||||
httptransport "github.com/go-openapi/runtime/client"
|
httptransport "github.com/go-openapi/runtime/client"
|
||||||
|
tb "github.com/nsf/termbox-go"
|
||||||
"github.com/openziti-test-kitchen/zrok/http"
|
"github.com/openziti-test-kitchen/zrok/http"
|
||||||
"github.com/openziti-test-kitchen/zrok/model"
|
"github.com/openziti-test-kitchen/zrok/model"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok"
|
||||||
@ -41,13 +45,11 @@ func newHttpCommand() *httpCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *httpCommand) run(_ *cobra.Command, args []string) {
|
func (self *httpCommand) run(_ *cobra.Command, args []string) {
|
||||||
/*
|
if err := ui.Init(); err != nil {
|
||||||
if err := ui.Init(); err != nil {
|
panic(err)
|
||||||
panic(err)
|
}
|
||||||
}
|
defer ui.Close()
|
||||||
defer ui.Close()
|
tb.SetInputMode(tb.InputEsc)
|
||||||
tb.SetInputMode(tb.InputEsc)
|
|
||||||
*/
|
|
||||||
|
|
||||||
idCfg, err := zrokdir.IdentityConfigFile()
|
idCfg, err := zrokdir.IdentityConfigFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -111,69 +113,64 @@ func (self *httpCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
/*
|
ui.Clear()
|
||||||
ui.Clear()
|
w, h := ui.TerminalDimensions()
|
||||||
w, h := ui.TerminalDimensions()
|
|
||||||
|
|
||||||
p := widgets.NewParagraph()
|
p := widgets.NewParagraph()
|
||||||
p.Border = true
|
p.Border = true
|
||||||
p.Title = " access your zrok service "
|
p.Title = " access your zrok service "
|
||||||
p.Text = fmt.Sprintf("%v%v", strings.Repeat(" ", (((w-12)-len(resp.Payload.ProxyEndpoint))/2)-1), resp.Payload.ProxyEndpoint)
|
p.Text = fmt.Sprintf("%v%v", strings.Repeat(" ", (((w-12)-len(resp.Payload.ProxyEndpoint))/2)-1), resp.Payload.ProxyEndpoint)
|
||||||
p.TextStyle = ui.Style{Fg: ui.ColorWhite}
|
p.TextStyle = ui.Style{Fg: ui.ColorWhite}
|
||||||
p.PaddingTop = 1
|
p.PaddingTop = 1
|
||||||
p.SetRect(5, 5, w-10, 10)
|
p.SetRect(5, 5, w-10, 10)
|
||||||
|
|
||||||
lastRequests := float64(0)
|
lastRequests := float64(0)
|
||||||
var requestData []float64
|
var requestData []float64
|
||||||
spk := widgets.NewSparkline()
|
spk := widgets.NewSparkline()
|
||||||
spk.Title = " requests "
|
spk.Title = " requests "
|
||||||
spk.Data = requestData
|
spk.Data = requestData
|
||||||
spk.LineColor = ui.ColorCyan
|
spk.LineColor = ui.ColorCyan
|
||||||
|
|
||||||
slg := widgets.NewSparklineGroup(spk)
|
slg := widgets.NewSparklineGroup(spk)
|
||||||
slg.SetRect(5, 11, w-10, h-5)
|
slg.SetRect(5, 11, w-10, h-5)
|
||||||
|
|
||||||
ui.Render(p, slg)
|
ui.Render(p, slg)
|
||||||
|
|
||||||
ticker := time.NewTicker(time.Second).C
|
ticker := time.NewTicker(time.Second).C
|
||||||
uiEvents := ui.PollEvents()
|
uiEvents := ui.PollEvents()
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case e := <-uiEvents:
|
|
||||||
switch e.Type {
|
|
||||||
case ui.ResizeEvent:
|
|
||||||
ui.Clear()
|
|
||||||
w, h = ui.TerminalDimensions()
|
|
||||||
p.SetRect(5, 5, w-10, 10)
|
|
||||||
slg.SetRect(5, 11, w-10, h-5)
|
|
||||||
ui.Render(p, slg)
|
|
||||||
|
|
||||||
case ui.KeyboardEvent:
|
|
||||||
switch e.ID {
|
|
||||||
case "q", "<C-c>":
|
|
||||||
ui.Close()
|
|
||||||
cleanupHttp(id, cfg, zrok, auth)
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case <-ticker:
|
|
||||||
currentRequests := float64(httpProxy.Requests())
|
|
||||||
deltaRequests := currentRequests - lastRequests
|
|
||||||
requestData = append(requestData, deltaRequests)
|
|
||||||
lastRequests = currentRequests
|
|
||||||
requestData = append(requestData, deltaRequests)
|
|
||||||
for len(requestData) > w-17 {
|
|
||||||
requestData = requestData[1:]
|
|
||||||
}
|
|
||||||
spk.Title = fmt.Sprintf(" requests (%d) ", int(currentRequests))
|
|
||||||
spk.Data = requestData
|
|
||||||
ui.Render(p, slg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
for {
|
for {
|
||||||
time.Sleep(30 * time.Second)
|
select {
|
||||||
|
case e := <-uiEvents:
|
||||||
|
switch e.Type {
|
||||||
|
case ui.ResizeEvent:
|
||||||
|
ui.Clear()
|
||||||
|
w, h = ui.TerminalDimensions()
|
||||||
|
p.SetRect(5, 5, w-10, 10)
|
||||||
|
slg.SetRect(5, 11, w-10, h-5)
|
||||||
|
ui.Render(p, slg)
|
||||||
|
|
||||||
|
case ui.KeyboardEvent:
|
||||||
|
switch e.ID {
|
||||||
|
case "q", "<C-c>":
|
||||||
|
ui.Close()
|
||||||
|
cleanupHttp(id, cfg, zrok, auth)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case <-ticker:
|
||||||
|
currentRequests := float64(httpProxy.Requests())
|
||||||
|
deltaRequests := currentRequests - lastRequests
|
||||||
|
requestData = append(requestData, deltaRequests)
|
||||||
|
lastRequests = currentRequests
|
||||||
|
requestData = append(requestData, deltaRequests)
|
||||||
|
for len(requestData) > w-17 {
|
||||||
|
requestData = requestData[1:]
|
||||||
|
}
|
||||||
|
spk.Title = fmt.Sprintf(" requests (%d) ", int(currentRequests))
|
||||||
|
spk.Data = requestData
|
||||||
|
ui.Render(p, slg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user