-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
Expected primary-expression before decltype CROW_MIDDLEWARES
#365
Comments
Hi! Currently CROW_MIDDLEWARES has to be used in the last place 😓 .methods(method) .CROW_MIDDLEWARES(this->app, M)(f) should do the job |
i've tried that too and it doesnt work template<unsigned N, const char(&url)[N], typename M, typename Func>
void add_route (crow::HTTPMethod&& method, Func f)
{
this->app.route<crow::black_magic::get_parameter_tag(url)>(url).methods(method)
.CROW_MIDDLEWARES(this->app, M)(f);
}
|
This code should work (clang13 / g++11 both swallow it). Note the template before middlwares() template<unsigned N, const char(&url)[N], typename M, typename Func>
void add_route(crow::HTTPMethod method, Func f) {
app.route<crow::black_magic::get_parameter_tag(url)>(url)
.methods(method)
.template middlewares<decltype(app), M>()(f);
} Unfortunately, Crow uses inconvenient constexpr char arrays for paths and the error becomes hard to decrypt 😀 . Now that your app.route() depends on your template arguments, .middlewares<> becomes a dependent template name and has to be prefixed with Btw, looks a little less confusing with macros. CROW_ROUTE(app, url)
.methods(method)
.template CROW_MIDDLEWARES(app, M)(f); Hope that helps |
I'll think about the implications of adding the template keyword to CROW_MIDDLEWARES. While it might technically be obsolete at times, it shouldn't break anything and would resolve such issues |
yes that worked thanks for the help |
Closing this issue as the initial problem was solved. See #369 for adding |
The above mentioned code gives me these errors
i am calling the function like this
this->add_route<sizeof(str), str, Authentificator>(crow::HTTPMethod::GET, [](){return "lol";});
and authentificator is defined like this
The text was updated successfully, but these errors were encountered: