diff --git a/router/router.go b/router/router.go index b44ccb325..15d935364 100644 --- a/router/router.go +++ b/router/router.go @@ -142,6 +142,12 @@ func Load(middleware ...gin.HandlerFunc) http.Handler { stream.GET("/:owner/:name/:build/:number", web.GetStream) } + slash := e.Group("/slash/slack") + { + slash.Use(session.MustUser()) + slash.POST("/slash", web.Slack) + } + auth := e.Group("/authorize") { auth.GET("", web.GetLogin) @@ -172,7 +178,7 @@ func normalize(h http.Handler) http.Handler { parts := strings.Split(r.URL.Path, "/")[1:] switch parts[0] { - case "settings", "repos", "api", "login", "logout", "", "authorize", "hook", "static", "gitlab": + case "settings", "slash", "repos", "api", "login", "logout", "", "authorize", "hook", "static", "gitlab": // no-op default: diff --git a/web/slack.go b/web/slack.go new file mode 100644 index 000000000..add479e73 --- /dev/null +++ b/web/slack.go @@ -0,0 +1,9 @@ +package web + +import "github.com/gin-gonic/gin" + +// Slack is handler function that handles Slack slash commands. +func Slack(c *gin.Context) { + text := c.PostForm("text") + c.String(200, "received message %s", text) +}