@@ -50,17 +50,21 @@ svr.listen_after_bind();
50
50
### Static File Server
51
51
52
52
``` cpp
53
- auto ret = svr.set_base_dir(" ./www" ); // This is same as `svr.set_base_dir("./www", "/")`;
53
+ // Mount / to ./www directory
54
+ auto ret = svr.set_mount_point(" ./www" , " /" );
54
55
if (!ret) {
55
56
// The specified base directory doesn't exist...
56
57
}
57
58
58
59
// Mount /public to ./www directory
59
- ret = svr.set_base_dir (" ./www" , " /public" );
60
+ ret = svr.set_mount_point (" ./www" , " /public" );
60
61
61
62
// Mount /public to ./www1 and ./www2 directories
62
- ret = svr.set_base_dir(" ./www1" , " /public" ); // 1st order to search
63
- ret = svr.set_base_dir(" ./www2" , " /public" ); // 2nd order to search
63
+ ret = svr.set_mount_point(" ./www1" , " /public" ); // 1st order to search
64
+ ret = svr.set_mount_point(" ./www2" , " /public" ); // 2nd order to search
65
+
66
+ // Remove mount /
67
+ ret = svr.remove_mount_point(" /" );
64
68
```
65
69
66
70
``` cpp
@@ -72,22 +76,24 @@ svr.set_file_extension_and_mimetype_mapping("hh", "text/x-h");
72
76
73
77
The followings are built-in mappings:
74
78
75
- | Extension | MIME Type |
76
- | :--------- | :--------------------- |
77
- | .txt | text/plain |
78
- | .html .htm | text/html |
79
- | .css | text/css |
80
- | .jpeg .jpg | image/jpg |
81
- | .png | image/png |
82
- | .gif | image/gif |
83
- | .svg | image/svg+xml |
84
- | .ico | image/x-icon |
85
- | .json | application/json |
86
- | .pdf | application/pdf |
87
- | .js | application/javascript |
88
- | .wasm | application/wasm |
89
- | .xml | application/xml |
90
- | .xhtml | application/xhtml+xml |
79
+ | Extension | MIME Type |
80
+ | :-------- | :--------------------- |
81
+ | txt | text/plain |
82
+ | html, htm | text/html |
83
+ | css | text/css |
84
+ | jpeg, jpg | image/jpg |
85
+ | png | image/png |
86
+ | gif | image/gif |
87
+ | svg | image/svg+xml |
88
+ | ico | image/x-icon |
89
+ | json | application/json |
90
+ | pdf | application/pdf |
91
+ | js | application/javascript |
92
+ | wasm | application/wasm |
93
+ | xml | application/xml |
94
+ | xhtml | application/xhtml+xml |
95
+
96
+ NOTE: These the static file server methods are not thread safe.
91
97
92
98
### Logging
93
99
0 commit comments