Skip to content

Commit

Permalink
TRPCHttpReqeust add trim_method_prefix() to prepare callee and func. (#…
Browse files Browse the repository at this point in the history
…390)

Co-authored-by: holmes1412 <liyingxin1412>
  • Loading branch information
holmes1412 authored Jun 6, 2024
1 parent 33dd3ea commit 794e697
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/message/rpc_message_trpc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,19 @@ bool TRPCRequest::trim_method_prefix()
return false;
}

bool TRPCHttpRequest::trim_method_prefix()
{
RequestProtocol *meta = static_cast<RequestProtocol *>(this->meta);
std::string *method = meta->mutable_func();

auto pos = method->find_last_of('/');
if (pos == std::string::npos)
return false;

meta->set_func(method->substr(pos + 1, method->length()));
return true;
}

bool TRPCResponse::set_meta_module_data(const RPCModuleData& data)
{
ResponseProtocol *meta = static_cast<ResponseProtocol *>(this->meta);
Expand Down
2 changes: 2 additions & 0 deletions src/message/rpc_message_trpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ class TRPCHttpRequest : public protocol::HttpRequest, public RPCRequest,
bool get_http_header(const std::string& name,
std::string& value) const override;

bool trim_method_prefix();

public:
TRPCHttpRequest() { this->size_limit = RPC_BODY_SIZE_LIMIT; }
};
Expand Down

0 comments on commit 794e697

Please sign in to comment.