Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.8.0
type Config struct {
SlackOAuthToken string
SlackUserToken string // optional user-level OAuth token (xoxp-)
SigningSecret string
DBUser string
DBPass string
DBHost string
DBName string
ListenPort string
GlobalAdmins []string
DBConnMaxLifetime time.Duration // max lifetime of a DB connection; 0 uses default (5m)
DBConnMaxIdleTime time.Duration // max idle time of a DB connection; 0 uses default (3m)
}
Config holds all configuration needed to initialize a Gadget instance.
func ConfigFromEnv ¶ added in v0.8.0
func ConfigFromEnv() Config
ConfigFromEnv returns a Config populated from environment variables.
type Gadget ¶
type Gadget struct {
Router router.Router
Client *slack.Client
UserClient *slack.Client // nil if no user token configured
// contains filtered or unexported fields
}
func SetupWithConfig ¶ added in v0.2.2
SetupWithConfig creates a new Gadget instance using the provided Config.
func (Gadget) Handler ¶ added in v0.3.0
Handler returns an http.Handler with all Gadget routes registered.
func (Gadget) Manifest ¶ added in v0.8.0
func (g Gadget) Manifest(name, description, requestURL string, extraScopes ...string) manifest.Manifest
Manifest generates a Slack app manifest from the currently registered routes. requestURL is the base URL where the bot is hosted (e.g. "https://example.com"). Additional OAuth scopes can be provided via extraScopes for scopes that cannot be inferred from route registrations. Note: called on a value receiver, so g.Router is copied at call time; routes registered after this call are not reflected in the returned manifest.
func (*Gadget) Use ¶ added in v0.8.0
func (g *Gadget) Use(mw Middleware)
Use appends a middleware to the chain. Middleware is executed in the order added, wrapping every handler invocation (mentions, channel messages, and slash commands).
type Middleware ¶ added in v0.8.0
type Middleware func(ctx router.HandlerContext, next func(router.HandlerContext))
Middleware wraps handler execution. Call next(ctx) to continue the chain, or return without calling next to short-circuit.