| 52 | } |
| 53 | |
| 54 | void APIServerImpl::Process(google::protobuf::RpcController* cntl_base, const HttpRequest*, HttpResponse*, |
| 55 | google::protobuf::Closure* done) { |
| 56 | brpc::ClosureGuard done_guard(done); |
| 57 | auto* cntl = dynamic_cast<brpc::Controller*>(cntl_base); |
| 58 | |
| 59 | // The unresolved path has no slashes at the beginning(guaranteed by brpc), it's not good for url parsing |
| 60 | auto unresolved_path = "/" + cntl->http_request().unresolved_path(); |
| 61 | auto method = cntl->http_request().method(); |
| 62 | DLOG(INFO) << "unresolved path: " << unresolved_path << ", method: " << HttpMethod2Str(method); |
| 63 | const butil::IOBuf& req_body = cntl->request_attachment(); |
| 64 | |
| 65 | JsonWriter writer; |
| 66 | provider_.handle(unresolved_path, method, req_body, writer); |
| 67 | |
| 68 | cntl->response_attachment().append(writer.GetString()); |
| 69 | } |
| 70 | |
| 71 | bool APIServerImpl::Json2SQLRequestRow(const butil::rapidjson::Value& non_common_cols_v, |
| 72 | const butil::rapidjson::Value& common_cols_v, |