Skip to content

Commit eb97ef1

Browse files
committed
mv apis stat into App
1 parent e17c4e0 commit eb97ef1

File tree

5 files changed

+23
-39
lines changed

5 files changed

+23
-39
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ project (ciao C CXX)
55
# some configuration.
66
set (CIAO_VERSION_MAJOR 0)
77
set (CIAO_VERSION_MINOR 0)
8-
set (CIAO_VERSION_PATCH 1)
8+
set (CIAO_VERSION_PATCH 4)
99
option (INJECT_BUILD_DATE "inject build date or not" ON)
1010

1111
configure_file (

ciao/api_stat.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

ciao/app.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,23 @@ class App {
282282
return *this;
283283
}
284284
// basic methods end.
285+
286+
// stat
287+
std::vector<std::pair<std::string, std::string>> stat() {
288+
std::vector<std::pair<std::string, std::string>> result;
289+
router->trie.walk_trie(result);
290+
return result;
291+
}
292+
293+
std::string text_stat() {
294+
std::vector<std::pair<std::string, std::string>> result = stat();
295+
std::string content;
296+
for (auto& r : result) {
297+
content += r.first + "\t" + r.second;
298+
content += "\n";
299+
}
300+
return content;
301+
}
285302
};
286303

287304
} // namespace ciao

ciao/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
22
#define CIAO_VERSION_MAJOR 0
33
#define CIAO_VERSION_MINOR 0
4-
#define CIAO_VERSION_PATCH 1
4+
#define CIAO_VERSION_PATCH 4
55
#define INJECT_BUILD_DATE
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
#include "ciao/api_stat.h"
2-
#include "ciao/utils.h"
1+
#include "ciao/app.h"
32
#include "test/test_common.h"
43

5-
TEST_F(UtilsTest, ApiStatTest) {
4+
TEST_F(AppTest, ApiStatTest) {
65
ciao::App app;
76
auto mw = [](ciao::Request& req, ciao::Response& res, ciao::Next& next) {};
87
app.get("/get", mw);
@@ -24,8 +23,7 @@ TEST_F(UtilsTest, ApiStatTest) {
2423
app.get("/article/view", mw);
2524
app.post("/article/modify", mw);
2625

27-
ciao::ApiStat api_stat(&app);
28-
auto stat = api_stat.stat();
26+
auto stat = app.stat();
2927
ASSERT_EQ(15lu, stat.size());
30-
std::cout << api_stat.text_stat() << std::endl;
28+
// std::cout << app.text_stat() << std::endl;
3129
}

0 commit comments

Comments
 (0)