Skip to content

Commit ac7742b

Browse files
committed
Changed the order of parameters of set_mounting_point.
1 parent 82c1116 commit ac7742b

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ svr.listen_after_bind();
5151

5252
```cpp
5353
// Mount / to ./www directory
54-
auto ret = svr.set_mount_point("./www", "/");
54+
auto ret = svr.set_mount_point("/", "./www");
5555
if (!ret) {
5656
// The specified base directory doesn't exist...
5757
}
5858

5959
// Mount /public to ./www directory
60-
ret = svr.set_mount_point("./www", "/public");
60+
ret = svr.set_mount_point("/public", "./www");
6161

6262
// Mount /public to ./www1 and ./www2 directories
63-
ret = svr.set_mount_point("./www1", "/public"); // 1st order to search
64-
ret = svr.set_mount_point("./www2", "/public"); // 2nd order to search
63+
ret = svr.set_mount_point("/public", "./www1"); // 1st order to search
64+
ret = svr.set_mount_point("/public", "./www2"); // 2nd order to search
6565

6666
// Remove mount /
6767
ret = svr.remove_mount_point("/");

example/simplesvr.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ int main(int argc, const char **argv) {
122122
auto base_dir = "./";
123123
if (argc > 2) { base_dir = argv[2]; }
124124

125-
if (!svr.set_mount_point(base_dir, "/")) {
125+
if (!svr.set_mount_point("/", base_dir)) {
126126
cout << "The specified base directory doesn't exist...";
127127
return 1;
128128
}

httplib.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ class Server {
466466
Server &Options(const char *pattern, Handler handler);
467467

468468
[[deprecated]] bool set_base_dir(const char *dir, const char *mount_point = nullptr);
469-
bool set_mount_point(const char *dir, const char *mount_point);
469+
bool set_mount_point(const char *mount_point, const char* dir);
470470
bool remove_mount_point(const char *mount_point);
471471
void set_file_extension_and_mimetype_mapping(const char *ext,
472472
const char *mime);
@@ -2891,10 +2891,10 @@ inline Server &Server::Options(const char *pattern, Handler handler) {
28912891
}
28922892

28932893
inline bool Server::set_base_dir(const char *dir, const char *mount_point) {
2894-
return set_mount_point(dir, mount_point);
2894+
return set_mount_point(mount_point, dir);
28952895
}
28962896

2897-
inline bool Server::set_mount_point(const char *dir, const char *mount_point) {
2897+
inline bool Server::set_mount_point(const char *mount_point, const char* dir) {
28982898
if (detail::is_dir(dir)) {
28992899
std::string mnt = mount_point ? mount_point : "/";
29002900
if (!mnt.empty() && mnt[0] == '/') {

test/test.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,8 @@ class ServerTest : public ::testing::Test {
662662
}
663663

664664
virtual void SetUp() {
665-
svr_.set_mount_point("./www", "/");
666-
svr_.set_mount_point("./www2", "/mount");
665+
svr_.set_mount_point("/", "./www");
666+
svr_.set_mount_point("/mount", "./www2");
667667
svr_.set_file_extension_and_mimetype_mapping("abcde", "text/abcde");
668668

669669
svr_.Get("/hi",
@@ -1245,7 +1245,7 @@ TEST_F(ServerTest, UserDefinedMIMETypeMapping) {
12451245
}
12461246

12471247
TEST_F(ServerTest, InvalidBaseDirMount) {
1248-
EXPECT_EQ(false, svr_.set_mount_point("./www3", "invalid_mount_point"));
1248+
EXPECT_EQ(false, svr_.set_mount_point("invalid_mount_point", "./www3"));
12491249
}
12501250

12511251
TEST_F(ServerTest, EmptyRequest) {
@@ -2082,7 +2082,7 @@ TEST(MountTest, Unmount) {
20822082

20832083
Client cli("localhost", PORT);
20842084

2085-
svr.set_mount_point("./www2", "/mount2");
2085+
svr.set_mount_point("/mount2", "./www2");
20862086

20872087
auto res = cli.Get("/");
20882088
ASSERT_TRUE(res != nullptr);
@@ -2092,7 +2092,7 @@ TEST(MountTest, Unmount) {
20922092
ASSERT_TRUE(res != nullptr);
20932093
EXPECT_EQ(200, res->status);
20942094

2095-
svr.set_mount_point("./www", "/");
2095+
svr.set_mount_point("/", "./www");
20962096

20972097
res = cli.Get("/dir/");
20982098
ASSERT_TRUE(res != nullptr);

0 commit comments

Comments
 (0)