Skip to content

Commit

Permalink
fix (examples): add gldap.OnClose func to example
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlambrt committed Oct 18, 2024
1 parent 8f791d9 commit c9cdc50
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion examples/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ func main() {
// a very simple way to track authenticated connections
authenticatedConnections := map[int]struct{}{}

// a gldap.OnClose function to clean up connections from the
// authenticatedConnections map when they are closed
onCloseFn := func(connId int) {
delete(authenticatedConnections, connId)
log.Printf("connection %d closed", connId)
}
// create a new server
s, err := gldap.NewServer(gldap.WithLogger(l), gldap.WithDisablePanicRecovery())
s, err := gldap.NewServer(gldap.WithLogger(l), gldap.WithDisablePanicRecovery(), gldap.WithOnClose(onCloseFn))
if err != nil {
log.Fatalf("unable to create server: %s", err.Error())
}
Expand Down

0 comments on commit c9cdc50

Please sign in to comment.