Fix #315
This commit is contained in:
parent
96e9ec0663
commit
04957c0f08
23
README.md
23
README.md
@ -50,23 +50,26 @@ svr.listen_after_bind();
|
|||||||
### Static File Server
|
### Static File Server
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
svr.set_base_dir("./www"); // This is same as `svr.set_base_dir("./www", "/")`;
|
auto ret = svr.set_base_dir("./www"); // This is same as `svr.set_base_dir("./www", "/")`;
|
||||||
|
if (!ret) {
|
||||||
|
// The specified base directory doesn't exist...
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mount /public to ./www directory
|
||||||
|
ret = svr.set_base_dir("./www", "/public");
|
||||||
|
|
||||||
|
// Mount /public to ./www1 and ./www2 directories
|
||||||
|
ret = svr.set_base_dir("./www1", "/public"); // 1st order to search
|
||||||
|
ret = svr.set_base_dir("./www2", "/public"); // 2nd order to search
|
||||||
|
```
|
||||||
|
|
||||||
|
```cpp
|
||||||
// User defined file extension and MIME type mappings
|
// User defined file extension and MIME type mappings
|
||||||
svr.set_file_extension_and_mimetype_mapping("cc", "text/x-c");
|
svr.set_file_extension_and_mimetype_mapping("cc", "text/x-c");
|
||||||
svr.set_file_extension_and_mimetype_mapping("cpp", "text/x-c");
|
svr.set_file_extension_and_mimetype_mapping("cpp", "text/x-c");
|
||||||
svr.set_file_extension_and_mimetype_mapping("hh", "text/x-h");
|
svr.set_file_extension_and_mimetype_mapping("hh", "text/x-h");
|
||||||
```
|
```
|
||||||
|
|
||||||
```cpp
|
|
||||||
svr.set_base_dir("./www", "/public");
|
|
||||||
```
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
svr.set_base_dir("./www1", "/public"); // 1st order
|
|
||||||
svr.set_base_dir("./www2", "/public"); // 2nd order
|
|
||||||
```
|
|
||||||
|
|
||||||
The followings are built-in mappings:
|
The followings are built-in mappings:
|
||||||
|
|
||||||
| Extension | MIME Type |
|
| Extension | MIME Type |
|
||||||
|
@ -122,7 +122,10 @@ int main(int argc, const char **argv) {
|
|||||||
auto base_dir = "./";
|
auto base_dir = "./";
|
||||||
if (argc > 2) { base_dir = argv[2]; }
|
if (argc > 2) { base_dir = argv[2]; }
|
||||||
|
|
||||||
svr.set_base_dir(base_dir);
|
if (!svr.set_base_dir(base_dir)) {
|
||||||
|
cout << "The specified base directory doesn't exist...";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
cout << "The server started at port " << port << "...";
|
cout << "The server started at port " << port << "...";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user