Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add POST versions of the message endpoints #191

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ authors = ["Evelina Gabasova <[email protected]>",
"Tomas Lazauskas <[email protected]>",
"David Beavan <[email protected]>",
"Levan Bokeria <[email protected]>",
"Martin O'Reilly <[email protected]>"]
"Martin O'Reilly <[email protected]>",
"Oliver Strickson <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
Expand Down
19 changes: 17 additions & 2 deletions reginald/models/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,32 @@ async def ping():
return "pong"

# set up direct_message endpoint
#
# See the note on the below 'POST' endpoint and consider deprecating
@app.get("/direct_message")
async def direct_message(query: Query):
response = response_model.direct_message(query.message, query.user_id)
return response
return response_model.direct_message(query.message, query.user_id)

# A POST direct_message endpoint, equivalent to the above.
# This provides a version of the endpoint that avoids a surprising use of
# the message body for a GET request. Provided as an additional endpoint
# instead of replacing the GET endpoint to avoid breaking things.
@app.post("/direct_message")
async def direct_message(query: Query):
return response_model.direct_message(query.message, query.user_id)

# set up channel_mention endpoint
@app.get("/channel_mention")
async def channel_mention(query: Query):
response = response_model.channel_mention(query.message, query.user_id)
return response

# POST channel_mention endpoint: see comment on direct_message
@app.post("/channel_mention")
async def channel_mention(query: Query):
response = response_model.channel_mention(query.message, query.user_id)
return response

uvicorn.run(app, host="0.0.0.0", port=8000)


Expand Down
Loading