mirror of
https://github.com/openziti/zrok.git
synced 2025-06-20 09:48:07 +02:00
fix --port flag shorthand in test endpoint; error handling (#67)
This commit is contained in:
parent
4e08dd379c
commit
222a494dbf
@ -38,10 +38,13 @@ func newTestEndpointCommand() *testEndpointCommand {
|
|||||||
command := &testEndpointCommand{cmd: cmd}
|
command := &testEndpointCommand{cmd: cmd}
|
||||||
var err error
|
var err error
|
||||||
if command.t, err = template.ParseFS(endpoint_ui.FS, "index.gohtml"); err != nil {
|
if command.t, err = template.ParseFS(endpoint_ui.FS, "index.gohtml"); err != nil {
|
||||||
|
if !panicInstead {
|
||||||
|
showError("unable to parse index template", err)
|
||||||
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
cmd.Flags().StringVarP(&command.address, "address", "a", "0.0.0.0", "The address for the HTTP listener")
|
cmd.Flags().StringVarP(&command.address, "address", "a", "0.0.0.0", "The address for the HTTP listener")
|
||||||
cmd.Flags().Uint16VarP(&command.port, "port", "p", 9090, "The port for the HTTP listener")
|
cmd.Flags().Uint16VarP(&command.port, "port", "P", 9090, "The port for the HTTP listener")
|
||||||
cmd.Run = command.run
|
cmd.Run = command.run
|
||||||
return command
|
return command
|
||||||
}
|
}
|
||||||
@ -49,6 +52,9 @@ func newTestEndpointCommand() *testEndpointCommand {
|
|||||||
func (cmd *testEndpointCommand) run(_ *cobra.Command, _ []string) {
|
func (cmd *testEndpointCommand) run(_ *cobra.Command, _ []string) {
|
||||||
http.HandleFunc("/", cmd.serveIndex)
|
http.HandleFunc("/", cmd.serveIndex)
|
||||||
if err := http.ListenAndServe(fmt.Sprintf("%v:%d", cmd.address, cmd.port), nil); err != nil {
|
if err := http.ListenAndServe(fmt.Sprintf("%v:%d", cmd.address, cmd.port), nil); err != nil {
|
||||||
|
if !panicInstead {
|
||||||
|
showError("unable to start http listener", err)
|
||||||
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user