Skip to content

Commit

Permalink
Merge pull request #191 from alan-turing-institute/post-endpoints
Browse files Browse the repository at this point in the history
Add POST versions of the message endpoints
  • Loading branch information
rchan26 authored Jun 12, 2024
2 parents 29558a5 + 57fcd1a commit a37292a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
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

0 comments on commit a37292a

Please sign in to comment.