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

no member named 'set_after_rpc_resp_fn' in 'brpc::Controller' #2854

Open
yellowkitee opened this issue Dec 19, 2024 · 1 comment
Open

no member named 'set_after_rpc_resp_fn' in 'brpc::Controller' #2854

yellowkitee opened this issue Dec 19, 2024 · 1 comment

Comments

@yellowkitee
Copy link

void Echo(google::protobuf::RpcController* cntl_base,
          const HttpRequest*,
          HttpResponse*,
          google::protobuf::Closure* done) {
    // This object helps you to call done->Run() in RAII style. If you need
    // to process the request asynchronously, pass done_guard.release().
    brpc::ClosureGuard done_guard(done);

    brpc::Controller* cntl =
        static_cast<brpc::Controller*>(cntl_base);

    // optional: set a callback function which is called after response is sent
    // and before cntl/req/res is destructed.
    **cntl->set_after_rpc_resp_fn(std::bind(&HttpServiceImpl::CallAfterRpc,**
        std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));

    // Fill response.
    cntl->http_response().set_content_type("text/plain");
    butil::IOBufBuilder os;
    os << "queries:";
    for (brpc::URI::QueryIterator it = cntl->http_request().uri().QueryBegin();
            it != cntl->http_request().uri().QueryEnd(); ++it) {
        os << ' ' << it->first << '=' << it->second;
    }
    os << "\nbody: " << cntl->request_attachment() << '\n';
    os.move_to(cntl->response_attachment());
}
@chenBright
Copy link
Contributor

Is the bRPC version too old?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants