Skip to content
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

Add the ability to use Routes::bind with constant member functions #1127

Merged
merged 1 commit into from
Mar 25, 2023

Conversation

tyler92
Copy link
Contributor

@tyler92 tyler92 commented Mar 24, 2023

There was a compile error with the following scenario:

class MyHttpServer
{
    // ...
    void run()
    {
        using namespace Pistache::Rest;
        Routes::Get(router, "/ping", Routes::bind(&MyHttpServer::requestHandler, this));
    }
    
    void requestHandler(const Pistache::Rest::Request& request,
                        Pistache::Http::ResponseWriter response) const
    {
        response.send(Pistache::Http::Code::Ok, "OK");
    }
    
    // ...
};

Compiler output:

main.cpp:38: error: no matching function for call to ‘bind(void (MyHttpServer::*)(const Pistache::Rest::Request&, Pistache::Http::ResponseWriter) const, MyHttpServer*)’
main.cpp: In member function ‘void MyHttpServer::run()’:
main.cpp:38:58: error: no matching function for call to ‘bind(void (MyHttpServer::*)(const Pistache::Rest::Request&, Pistache::Http::ResponseWriter) const, MyHttpServer*)’
   38 |                 Routes::Get(router, "/ping", Routes::bind(&MyHttpServer::requestHandler, this));
      |    

@codecov-commenter
Copy link

codecov-commenter commented Mar 24, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.04 🎉

Comparison is base (7f6bb27) 78.45% compared to head (675b6f0) 78.49%.

❗ Current head 675b6f0 differs from pull request most recent head fa6e5da. Consider uploading reports for the commit fa6e5da to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1127      +/-   ##
==========================================
+ Coverage   78.45%   78.49%   +0.04%     
==========================================
  Files          53       53              
  Lines        6879     6892      +13     
==========================================
+ Hits         5397     5410      +13     
  Misses       1482     1482              
Impacted Files Coverage Δ
include/pistache/router.h 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@dennisjenkins75 dennisjenkins75 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for the contribution.

@kiplingw
Copy link
Member

@Tachi107, if you're fine with it too, I'll merge.

@Tachi107
Copy link
Member

Thanks for the patch! Looks good to me as well

@kiplingw kiplingw merged commit a68ad09 into pistacheio:master Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants