Documentation
¶
Index ¶
- func RegisterCallback[Req any, Resp any](s *Server, command string, fn func(c *gin.Context, req *Req) (*Resp, error))
- type RequestRecord
- type Server
- func (s *Server) ClearHistory()
- func (s *Server) GetHistory() []RequestRecord
- func (s *Server) OnRequest(hook func(command string, reqBody []byte, c *gin.Context))
- func (s *Server) RegisterDefaultHandlers()
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) SetRecordHistory(enabled bool)
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) Start(addr string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type RequestRecord ¶
RequestRecord stores information about a received webhook request.
type Server ¶
Server is a mock webhook HTTP server for OpenIM callbacks.
func (*Server) ClearHistory ¶
func (s *Server) ClearHistory()
ClearHistory clears all recorded request history.
func (*Server) GetHistory ¶
func (s *Server) GetHistory() []RequestRecord
GetHistory returns a copy of all recorded requests.
func (*Server) OnRequest ¶
OnRequest sets a callback function invoked whenever any webhook request arrives.
func (*Server) RegisterDefaultHandlers ¶
func (s *Server) RegisterDefaultHandlers()
RegisterDefaultHandlers registers default success handlers for all supported OpenIM webhook commands.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP conforms to the http.Handler interface.
func (*Server) SetRecordHistory ¶
SetRecordHistory enables or disables recording incoming request history.
Click to show internal directories.
Click to hide internal directories.