Help us shape the future of Go! Take the 2026 Go Developer Survey

httpserver

package
v0.6.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	URL:  "/interactions/callback",
	Port: ":80",
}

Functions

func Verify

func Verify(logger log.Logger, r *http.Request, key ed25519.PublicKey) bool

Verify 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
	EventHandlerFunc EventHandlerFunc
	URL              string
	Port             string
	PublicKey        string
	CertFile         string
	KeyFile          string
}

func (*Config) Apply

func (c *Config) Apply(opts []ConfigOpt)

type ConfigOpt

type ConfigOpt func(config *Config)

func WithHTTPServer

func WithHTTPServer(httpServer *http.Server) ConfigOpt

func WithLogger

func WithLogger(logger log.Logger) ConfigOpt

func WithPort

func WithPort(port string) ConfigOpt

func WithPublicKey

func WithPublicKey(publicKey string) ConfigOpt

func WithServeMux

func WithServeMux(serveMux *http.ServeMux) ConfigOpt

func WithTLS

func WithTLS(certFile string, keyFile string) ConfigOpt

func WithURL

func WithURL(url string) ConfigOpt

type EventHandlerFunc

type EventHandlerFunc func(responseChannel chan<- discord.InteractionResponse, payload io.Reader)

type Server

type Server interface {
	Logger() log.Logger
	PublicKey() ed25519.PublicKey
	Config() Config
	Start()
	Close(ctx context.Context) error
}

Server is used for receiving an Interaction over httpserver

func New

func New(eventHandlerFunc EventHandlerFunc, config *Config) Server

type WebhookInteractionHandler

type WebhookInteractionHandler struct {
	// contains filtered or unexported fields
}

func (*WebhookInteractionHandler) ServeHTTP

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL