Skip to content

Commit

Permalink
Add POST versions of the message endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
ots22 committed Jun 11, 2024
1 parent 318d2cf commit f656654
Showing 1 changed file with 17 additions and 2 deletions.
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 f656654

Please sign in to comment.