Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Verify reports whether sig is a valid signature of message by publicKey. It Verify = func(publicKey PublicKey, message []byte, sig []byte) bool { return ed25519.Verify(publicKey, message, sig) } // SignatureSize is the size, in bytes, of signatures generated and verified by this package. SignatureSize = ed25519.SignatureSize )
Functions ¶
func VerifyRequest ¶
VerifyRequest implements the verification side of the discord interactions api signing algorithm, as documented here: https://discord.com/developers/docs/interactions/slash-commands#security-and-authorization Credit: https://github.com/bsdlp/discord-interactions-go/blob/main/interactions/verify.go
Types ¶
type Config ¶
type Config struct { Logger log.Logger HTTPServer *http.Server ServeMux *http.ServeMux URL string Address string CertFile string KeyFile string }
Config lets you configure your Server instance.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with sensible defaults.
type ConfigOpt ¶
type ConfigOpt func(config *Config)
ConfigOpt is a type alias for a function that takes a Config and is used to configure your Server.
func WithAddress ¶
WithAddress sets the Address of the Config.
func WithHTTPServer ¶
WithHTTPServer sets the http.Server of the Config.
func WithLogger ¶
WithLogger sets the Logger of the Config.
func WithServeMux ¶
WithServeMux sets the http.ServeMux of the Config.
type EventHandlerFunc ¶
type EventHandlerFunc func(responseFunc RespondFunc, event gateway.EventInteractionCreate)
EventHandlerFunc is used to handle events from Discord's Outgoing Webhooks
type RespondFunc ¶ added in v0.8.9
type RespondFunc func(response discord.InteractionResponse) error
RespondFunc is used to respond to Discord's Outgoing Webhooks
type Server ¶
type Server interface { // Logger returns the logger used by the Server Logger() log.Logger // PublicKey returns the public key used by the Server PublicKey() PublicKey // Start starts the Server Start() // Close closes the Server Close(ctx context.Context) // Handle passes a payload to the Server for processing Handle(respondFunc RespondFunc, event gateway.EventInteractionCreate) }
Server is used for receiving Discord's interactions via Outgoing Webhooks
type WebhookInteractionHandler ¶
type WebhookInteractionHandler struct {
// contains filtered or unexported fields
}
WebhookInteractionHandler implements the http.Handler interface and is used to handle interactions from Discord.
func (*WebhookInteractionHandler) ServeHTTP ¶
func (h *WebhookInteractionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)