MCPcopy
hub / github.com/mochi-mqtt/server / AddHook

Method AddHook

server.go:265–273  ·  view source on GitHub ↗

AddHook attaches a new Hook to the server. Ideally, this should be called before the server is started with s.Serve().

(hook Hook, config any)

Source from the content-addressed store, hash-verified

263// AddHook attaches a new Hook to the server. Ideally, this should be called
264// before the server is started with s.Serve().
265func (s *Server) AddHook(hook Hook, config any) error {
266 nl := s.Log.With("hook", hook.ID())
267 hook.SetOpts(nl, &HookOptions{
268 Capabilities: s.Options.Capabilities,
269 })
270
271 s.Log.Info("added hook", "hook", hook.ID())
272 return s.hooks.Add(hook, config)
273}
274
275// AddHooksFromConfig adds hooks to the server which were specified in the hooks config (usually from a config file).
276// New built-in hooks should be added to this list.

Calls 3

IDMethod · 0.65
SetOptsMethod · 0.65
AddMethod · 0.45