No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.mvn/wrapper
src
.gitignore
README.md
mvnw
mvnw.cmd
pom.xml

README.md

Slack Slash Command Example

This repo demonstrates 3 approaches to handling Form POSTs in a similar way to handling JSON POSTs in a Spring Boot app.

Check out (and please vote for) the Spring Boot Jira issue that would make all 3 of these approaches unnecessary.

For a deeper explanation, read the blog post about it.

You can also see a lively conversation that kicked all this off on r/java.

Build & Run

mvn clean install
java -jar slack-slash-command-example-0.0.1-SNAPSHOT.jar 

Exercise

The follow examples use HTTPie

In each case, you should get back the same parameters as a JSON object.

Automatic HttpMessageConverter approach

http -f POST localhost:8080/api/v1/slack3 \
  token=token team_id=team_id team_domain=team_domain channel_id=channel_id \
  channel_name=channel_name user_id=user_id user_name=user_name \
  command=command text=text response_url=response_url

HandlerMethodArgumentResolver approach

http -f POST localhost:8080/api/v1/slack2 \
  token=token team_id=team_id team_domain=team_domain channel_id=channel_id \
  channel_name=channel_name user_id=user_id user_name=user_name \
  command=command text=text response_url=response_url

HttpMessageConverter approach - custom

http -f POST localhost:8080/api/v1/slack \
  token=token team_id=team_id team_domain=team_domain channel_id=channel_id \
  channel_name=channel_name user_id=user_id user_name=user_name \
  command=command text=text response_url=response_url