MCPcopy Create free account
hub / github.com/apache/brpc / no_method

Method no_method

src/brpc/builtin/bad_method_service.cpp:34–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32namespace brpc {
33
34void BadMethodService::no_method(::google::protobuf::RpcController* cntl_base,
35 const BadMethodRequest* request,
36 BadMethodResponse*,
37 ::google::protobuf::Closure* done) {
38 ClosureGuard done_guard(done);
39 Controller *cntl = static_cast<Controller*>(cntl_base);
40 const Server* server = cntl->server();
41 const bool use_html = UseHTML(cntl->http_request());
42 const char* newline = (use_html ? "<br>\n" : "\n");
43 cntl->http_response().set_content_type(
44 use_html ? "text/html" : "text/plain");
45
46 std::ostringstream os;
47 os << "Missing method name for service=" << request->service_name() << '.';
48 const Server::ServiceProperty* sp = ServerPrivateAccessor(server)
49 .FindServicePropertyAdaptively(request->service_name());
50 if (sp != NULL && sp->service != NULL) {
51 const google::protobuf::ServiceDescriptor* sd =
52 sp->service->GetDescriptor();
53 os << " Available methods are: " << newline << newline;
54 for (int i = 0; i < sd->method_count(); ++i) {
55 os << "rpc " << sd->method(i)->name()
56 << " (" << sd->method(i)->input_type()->name()
57 << ") returns (" << sd->method(i)->output_type()->name()
58 << ");" << newline;
59 }
60 }
61 if (sp != NULL && sp->restful_map != NULL) {
62 os << " This path is associated with a RestfulMap!";
63 }
64 cntl->SetFailed(ENOMETHOD, "%s", os.str().c_str());
65}
66
67} // namespace brpc

Callers 1

TestBadMethodMethod · 0.80

Calls 11

UseHTMLFunction · 0.85
set_content_typeMethod · 0.80
service_nameMethod · 0.80
serverMethod · 0.45
GetDescriptorMethod · 0.45
nameMethod · 0.45
methodMethod · 0.45
SetFailedMethod · 0.45
c_strMethod · 0.45

Tested by 1

TestBadMethodMethod · 0.64