diff --git a/handle.go b/handle.go index b596ee6..10acec9 100644 --- a/handle.go +++ b/handle.go @@ -103,7 +103,7 @@ func CreateHttpHandlerWithLogger(handlers Handlers, loggerCreator CreateLogger) logger.Debugf("Skill execution took %d ms", time.Now().UnixMilli()-start.UnixMilli()) }() - if handle, ok := handlers[name]; ok { + if handle, ok := handlers(name); ok { logger.Debugf("Invoking event handler '%s'", name) err = SendStatus(ctx, req, Status{ diff --git a/types.go b/types.go index 5c3d599..2cd8005 100644 --- a/types.go +++ b/types.go @@ -148,4 +148,11 @@ func (r *RequestContext) NewTransaction() Transaction { type EventHandler func(ctx context.Context, req RequestContext) Status -type Handlers map[string]EventHandler +type Handlers func(name string) (EventHandler, bool) + +func HandlersFromMap(handlers map[string]EventHandler) Handlers { + return func(name string) (EventHandler, bool) { + handle, ok := handlers[name] + return handle, ok + } +}