You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* added not found handler to mux
* add HandleNotFound into interface
* removed redundant handle prefixes in mux
* fix panic
* remove NotFound method from Router & export Mux type
* add not found handler to handler example
* add docs
---------
Co-authored-by: TopiSenpai <[email protected]>
Copy file name to clipboardExpand all lines: handler/handler.go
+18-1Lines changed: 18 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,20 @@
1
+
// Package handler provides a way to handle interactions like application commands, autocomplete, buttons, select menus & modals with a simple interface.
2
+
//
3
+
// The handler package is inspired by the go-chi/chi http router.
4
+
// Each interaction has a path which is either the command name (starting with /) or the custom id. According to this path all interactions are routed to the correct handler.
5
+
// Slash Commands can have subcommands, which are nested paths. For example /test/subcommand1 or /test/subcommandgroup/subcommand.
6
+
//
7
+
// The handler also supports variables in its path which is especially useful for subcommands, components and modals.
8
+
// Variables are defined by curly braces like {variable} and can be accessed in the handler via the Variables map.
9
+
//
10
+
// You can also register middlewares, which are executed before the handler is called. Middlewares can be used to check permissions, validate input or do other things.
11
+
// Middlewares can also be attached to sub-routers, which is useful if you want to have a middleware for all subcommands of a command as an example.
12
+
// A middleware does not care which interaction type it is, it is just executed before the handler and has the following signature:
13
+
// type Middleware func(next func(e *events.InteractionCreate)) func(e *events.InteractionCreate)
14
+
//
15
+
// The handler iterates over all routes until it finds the fist matching route. If no route matches, the handler will call the NotFoundHandler.
16
+
// The NotFoundHandler can be set via the `NotFound` method on the *Mux. If no NotFoundHandler is set nothing will happen.
0 commit comments