This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"message_id": "1234567890", | |
"chat_id": "chat-123", | |
"author_id": "user-456", | |
"text": "this is a message", | |
"date_created": "2020-11-28 13:15:09+00:00" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Here is a more complicated endpoint that retrieve objects | |
# from datastore in multiple phases, and build up a queue of objects | |
# to bulk commit at the end | |
from pymacaron.auth import get_userid | |
def do_get_recommended_new_friends(data): | |
cache = ObjectCache() | |
saver = ObjectSaver(cache=cache) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymacaron.auth import get_userid | |
# Implements an hypothetical endpoint that let's a user (identified by a JWT token) | |
# add another user as friend (identified by its user ID in the data object received | |
# as parameter, mapping to the POST request's body) | |
def do_add_friend(data): | |
viewer_id = get_userid() # Extract the ID of the current user from its JWT auth token | |
friend_id = data.user_id # And 'user_id' in the POST request is the friend's ID |
NewerOlder