mirror of
https://github.com/openziti/zrok.git
synced 2025-01-11 00:18:43 +01: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}
|
||||
var err error
|
||||
if command.t, err = template.ParseFS(endpoint_ui.FS, "index.gohtml"); err != nil {
|
||||
if !panicInstead {
|
||||
showError("unable to parse index template", err)
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
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
|
||||
return command
|
||||
}
|
||||
@ -49,6 +52,9 @@ func newTestEndpointCommand() *testEndpointCommand {
|
||||
func (cmd *testEndpointCommand) run(_ *cobra.Command, _ []string) {
|
||||
http.HandleFunc("/", cmd.serveIndex)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user