Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
robiball committed Oct 25, 2019
1 parent 7092d46 commit ca9554e
Show file tree
Hide file tree
Showing 491 changed files with 83,769 additions and 23,870 deletions.
120 changes: 60 additions & 60 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
# unused-packages = true

[[constraint]]
branch = "master"
name = "github.com/nlopes/slack"
version = "0.6.0"

[prune]
go-tests = true
Expand Down
20 changes: 18 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package server

import (
"encoding/json"
"io/ioutil"
"net/http"
"strings"
"github.com/nlopes/slack"
"github.com/nlopes/slack/slackevents"
)

// LogFunc is an abstraction that allows using any external logger with a Print signature
Expand Down Expand Up @@ -84,8 +87,6 @@ func (h *SlackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
req := &Request{Request: r}
res := &Response{w}

h.Logf("Request: %s+", req)

// Generic serve function which captures and logs handler errors
serve := func(f SlackHandlerFunc, ctx interface{}) {
if err := f(res, req, ctx); err != nil {
Expand Down Expand Up @@ -118,6 +119,20 @@ func (h *SlackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}

h.Logf("Form: %s+", r.Form)
h.Logf("Body: %s", r.Body)

body, err := ioutil.ReadAll(r.Body)
if err == nil {
var challenge slackevents.EventsAPIURLVerificationEvent
// This has a body, lets do stuff with it
err := json.Unmarshal(body, &challenge)
if err != nil {
//t.Error(err)
}
h.Logf("CHALLENGE: %s+", challenge)
}

// Does it have a valid callback payload? - If so, it's a callback
payload, err := req.CallbackPayload()
if err != nil {
Expand All @@ -126,6 +141,7 @@ func (h *SlackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Loop through all our routes and attempt a match on the InteractionType / CallbackID pair
if payload != nil {
for _, rt := range h.Routes {

if string(payload.Type) == rt.InteractionType && payload.CallbackID == rt.CallbackID {
// Send the payload as context
serve(rt.Handler, payload)
Expand Down
19 changes: 0 additions & 19 deletions vendor/github.com/gorilla/websocket/.travis.yml

This file was deleted.

10 changes: 5 additions & 5 deletions vendor/github.com/gorilla/websocket/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/gorilla/websocket/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ca9554e

Please sign in to comment.