Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
4eea7377
Commit
4eea7377
authored
Sep 01, 2020
by
wxf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accessing via default url
parent
d50f3fa9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
brpc_server_unittest.cpp
test/brpc_server_unittest.cpp
+35
-0
No files found.
test/brpc_server_unittest.cpp
View file @
4eea7377
...
...
@@ -669,6 +669,16 @@ TEST_F(ServerTest, restful_mapping) {
" /v1/*/* => Echo"
));
ASSERT_EQ
(
0u
,
server9
.
service_count
());
// default url access
brpc
::
Server
server10
;
ASSERT_EQ
(
0
,
server10
.
AddService
(
&
service_v1
,
brpc
::
SERVER_DOESNT_OWN_SERVICE
,
"/v1/echo => Echo"
,
true
));
ASSERT_EQ
(
1u
,
server10
.
service_count
());
ASSERT_FALSE
(
server10
.
_global_restful_map
);
// Access services
ASSERT_EQ
(
0
,
server1
.
Start
(
port
,
NULL
));
brpc
::
Channel
http_channel
;
...
...
@@ -867,6 +877,31 @@ TEST_F(ServerTest, restful_mapping) {
server1
.
Stop
(
0
);
server1
.
Join
();
ASSERT_EQ
(
0
,
server10
.
Start
(
port
,
NULL
));
// access v1.Echo via /v1/echo.
cntl
.
Reset
();
cntl
.
http_request
().
uri
()
=
"/v1/echo"
;
cntl
.
http_request
().
set_method
(
brpc
::
HTTP_METHOD_POST
);
cntl
.
request_attachment
().
append
(
"{
\"
message
\"
:
\"
foo
\"
}"
);
http_channel
.
CallMethod
(
NULL
,
&
cntl
,
NULL
,
NULL
,
NULL
);
ASSERT_FALSE
(
cntl
.
Failed
())
<<
cntl
.
ErrorText
();
ASSERT_EQ
(
12
,
service_v1
.
ncalled
.
load
());
ASSERT_EQ
(
"{
\"
message
\"
:
\"
foo_v1
\"
}"
,
cntl
.
response_attachment
());
// access v1.Echo via default url
cntl
.
Reset
();
cntl
.
http_request
().
uri
()
=
"/EchoService/Echo"
;
cntl
.
http_request
().
set_method
(
brpc
::
HTTP_METHOD_POST
);
cntl
.
request_attachment
().
append
(
"{
\"
message
\"
:
\"
foo
\"
}"
);
http_channel
.
CallMethod
(
NULL
,
&
cntl
,
NULL
,
NULL
,
NULL
);
ASSERT_FALSE
(
cntl
.
Failed
())
<<
cntl
.
ErrorText
();
ASSERT_EQ
(
13
,
service_v1
.
ncalled
.
load
());
ASSERT_EQ
(
"{
\"
message
\"
:
\"
foo_v1
\"
}"
,
cntl
.
response_attachment
());
server10
.
Stop
(
0
);
server10
.
Join
();
// Removing the service should update _global_restful_map.
ASSERT_EQ
(
0
,
server1
.
RemoveService
(
&
service_v1
));
ASSERT_EQ
(
0u
,
server1
.
service_count
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment