Documentation ¶
Index ¶
- type LogFunc
- type LogfFunc
- type Request
- type Response
- type Route
- type SlackHandler
- func (h *SlackHandler) HandleCommand(c string, f SlackHandlerFunc)
- func (h *SlackHandler) HandleEventCallback(et string, f SlackHandlerFunc)
- func (h *SlackHandler) HandleInteractionCallback(it, cid string, f SlackHandlerFunc)
- func (h *SlackHandler) HandlePath(p string, f SlackHandlerFunc)
- func (h *SlackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type SlackHandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogFunc ¶
type LogFunc func(...interface{})
LogFunc is an abstraction that allows using any external logger with a Print signature Set to nil to disable logging completely
type LogfFunc ¶
type LogfFunc func(string, ...interface{})
LogfFunc is an abstraction that allows using any external logger with a Printf signature Set to nil to disable logging completely
type Request ¶
Request wraps http.Request
func (*Request) EventAPIEvent ¶
func (r *Request) EventAPIEvent(body []byte) (*slackevents.EventsAPIEvent, error)
EventAPIEvent returns the parsed event from the Slack Event API if it exists and is valid
func (*Request) InteractionCallbackPayload ¶
func (r *Request) InteractionCallbackPayload() (*slack.InteractionCallback, error)
InteractionCallbackPayload returns the parsed payload for an interaction if it exists and is valid
type Route ¶
type Route struct {
CallbackID, Path, Command, InteractionType, EventType string
Handler SlackHandlerFunc
}
Route is a handler which is invoked when a path is matched
type SlackHandler ¶
type SlackHandler struct { Log LogFunc Logf LogfFunc ErrorLog LogFunc ErrorLogf LogfFunc Routes []*Route DefaultRoute SlackHandlerFunc // contains filtered or unexported fields }
SlackHandler is a function executed when a route is invoked
func NewSlackHandler ¶
func NewSlackHandler(basePath, appToken, secretToken string, dnHeader *string, l LogFunc, lf LogfFunc, el LogFunc, elf LogfFunc) *SlackHandler
NewSlackHandler returns an initialised SlackHandler
func (*SlackHandler) HandleCommand ¶
func (h *SlackHandler) HandleCommand(c string, f SlackHandlerFunc)
HandleCommand registers a handler to be executed when a slash command request is sent to the BasePath
func (*SlackHandler) HandleEventCallback ¶
func (h *SlackHandler) HandleEventCallback(et string, f SlackHandlerFunc)
HandleEventCallback registers a handler to be executed when a specific EventsAPICallbackEvent type is present in the request
func (*SlackHandler) HandleInteractionCallback ¶
func (h *SlackHandler) HandleInteractionCallback(it, cid string, f SlackHandlerFunc)
HandleInteractionCallback registers a handler to be executed when a specific InteractionType / CallbackID pair is present in the request
func (*SlackHandler) HandlePath ¶
func (h *SlackHandler) HandlePath(p string, f SlackHandlerFunc)
HandlePath registers handlers for specific paths
func (*SlackHandler) ServeHTTP ¶
func (h *SlackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP satisfies http.Handler interface
type SlackHandlerFunc ¶
SlackHandlerFunc is an http.HandlerFunc which can return an error and has a context Context varies depending on the request type and is for injecting arbitrary data in at routing time