Skip to content
Discussion options

You must be logged in to vote

@capybaracplusplus you should declare your methods like follows:

drogon::Task<drogon::HttpResponsePtr> createShortLink(drogon::HttpRequestPtr req);
drogon::Task<drogon::HttpResponsePtr> redirectToOriginal(drogon::HttpRequestPtr req,
                                                             std::string hash);

The reason is explained in the document you pasted:
Passing most parameters by value is a direct consequence of coroutines being asynchronous. It's impossible to track when a reference goes out of scope as the object may destruct while the coroutine is waiting. Or the reference may live on another thread. Thus, it may destruct while the coroutine is executing.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by capybaracplusplus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants