Skip to content

Commit

Permalink
renamed OnListenerStart callback to OnBind internally, too
Browse files Browse the repository at this point in the history
  • Loading branch information
flrdv committed Apr 26, 2024
1 parent 8101c84 commit 0de0999
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions indi.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (a *App) OnStart(cb func()) *App {

// OnBind calls the passed callback for every address, that was bound without any errors
func (a *App) OnBind(cb func(addr string)) *App {
a.hooks.OnListenerStart = cb
a.hooks.OnBind = cb
return a
}

Expand Down Expand Up @@ -136,8 +136,8 @@ func (a *App) bind(r router.Router) ([]*tcp.Server, error) {
src.Handler = a.newHTTPHandler(encryption.Plain)
}

if a.hooks.OnListenerStart != nil {
a.hooks.OnListenerStart(src.Addr)
if a.hooks.OnBind != nil {
a.hooks.OnBind(src.Addr)
}

servers = append(servers, tcp.NewServer(listener, func(conn net.Conn) {
Expand Down Expand Up @@ -199,9 +199,9 @@ func (a *App) newHTTPHandler(enc encryption.Token) listenerHandler {
}

type hooks struct {
OnStart func()
OnListenerStart func(addr string)
OnStop func()
OnStart func()
OnBind func(addr string)
OnStop func()
}

func callIfNotNil(f func()) {
Expand Down

0 comments on commit 0de0999

Please sign in to comment.