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)
| 263 | // AddHook attaches a new Hook to the server. Ideally, this should be called |
| 264 | // before the server is started with s.Serve(). |
| 265 | func (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. |