@@ -46,7 +46,7 @@ RewriteRule . index.html
46
46
47
47
Contains base handler:
48
48
```
49
- WSJCppLightWebHttpHandlerRewriteFolder (sPrefixPath, sDirPath)
49
+ WsjcppLightWebHttpHandlerRewriteFolder (sPrefixPath, sDirPath)
50
50
```
51
51
Where
52
52
* sPrefixPath - like "/app1/" -> "http://localhost:1234/app1/ "
@@ -61,10 +61,10 @@ Example init, add handler and start server
61
61
#include <wsjcpp_light_web_http_handler_rewrite_folder.h>
62
62
63
63
...
64
- WSJCppLightWebServer httpServer;
64
+ WsjcppLightWebServer httpServer;
65
65
httpServer.setPort(1234);
66
66
httpServer.setMaxWorkers(1);
67
- httpServer.addHandler((WSJCppLightWebHttpHandlerBase *)new WSJCppLightWebHttpHandlerRewriteFolder ("/app1/", "./web"));
67
+ httpServer.addHandler((WsjcppLightWebHttpHandlerBase *)new WsjcppLightWebHttpHandlerRewriteFolder ("/app1/", "./web"));
68
68
httpServer.startSync(); // this method will be hold current thread, if you with you can call just start/stop command
69
69
```
70
70
@@ -74,7 +74,7 @@ After compile and start will be available on `http://localhost:1234/app1/`
74
74
75
75
Contains base handler:
76
76
```
77
- WSJCppLightWebHttpHandlerWebFolder (sPrefixPath, sDirPath)
77
+ WsjcppLightWebHttpHandlerWebFolder (sPrefixPath, sDirPath)
78
78
```
79
79
80
80
Where
@@ -88,10 +88,10 @@ Example init, add handler and start server
88
88
#include <wsjcpp_light_web_http_handler_web_folder.h>
89
89
90
90
...
91
- WSJCppLightWebServer httpServer;
91
+ WsjcppLightWebServer httpServer;
92
92
httpServer.setPort(1234);
93
93
httpServer.setMaxWorkers(1);
94
- httpServer.addHandler((WSJCppLightWebHttpHandlerBase *)new WSJCppLightWebHttpHandlerWebFolder ("/app2/", "./web"));
94
+ httpServer.addHandler((WsjcppLightWebHttpHandlerBase *)new WsjcppLightWebHttpHandlerWebFolder ("/app2/", "./web"));
95
95
httpServer.startSync(); // this method will be hold current thread, if you with you can call just start/stop command
96
96
```
97
97
@@ -108,11 +108,11 @@ header-file `http_handler_custom.h`:
108
108
109
109
#include <wsjcpp_light_web_server.h>
110
110
111
- class HttpHandlerCustom : WSJCppLightWebHttpHandlerBase {
111
+ class HttpHandlerCustom : WsjcppLightWebHttpHandlerBase {
112
112
public:
113
113
HttpHandlerCustom();
114
- virtual bool canHandle(const std::string &sWorkerId, WSJCppLightWebHttpRequest *pRequest);
115
- virtual bool handle(const std::string &sWorkerId, WSJCppLightWebHttpRequest *pRequest);
114
+ virtual bool canHandle(const std::string &sWorkerId, WsjcppLightWebHttpRequest *pRequest);
115
+ virtual bool handle(const std::string &sWorkerId, WsjcppLightWebHttpRequest *pRequest);
116
116
117
117
private:
118
118
std::string TAG;
@@ -128,13 +128,13 @@ source-file `http_handler_custom.cpp`:
128
128
// ----------------------------------------------------------------------
129
129
130
130
HttpHandlerCustom::HttpHandlerCustom()
131
- : WSJCppLightWebHttpHandlerBase ("custom") {
131
+ : WsjcppLightWebHttpHandlerBase ("custom") {
132
132
TAG = "HttpHandlerCustom";
133
133
}
134
134
135
135
// ----------------------------------------------------------------------
136
136
137
- bool HttpHandlerCustom::canHandle(const std::string &sWorkerId, WSJCppLightWebHttpRequest *pRequest) {
137
+ bool HttpHandlerCustom::canHandle(const std::string &sWorkerId, WsjcppLightWebHttpRequest *pRequest) {
138
138
std::string _tag = TAG + "-" + sWorkerId;
139
139
std::string sRequestPath = pRequest->getRequestPath();
140
140
@@ -149,12 +149,12 @@ bool HttpHandlerCustom::canHandle(const std::string &sWorkerId, WSJCppLightWebHt
149
149
150
150
// ----------------------------------------------------------------------
151
151
152
- bool HttpHandlerCustom::handle(const std::string &sWorkerId, WSJCppLightWebHttpRequest *pRequest) {
152
+ bool HttpHandlerCustom::handle(const std::string &sWorkerId, WsjcppLightWebHttpRequest *pRequest) {
153
153
std::string _tag = TAG + "-" + sWorkerId;
154
154
std::string sRequestPath = pRequest->getRequestPath();
155
- // WSJCppLog ::warn(_tag, sRequestPath);
155
+ // WsjcppLog ::warn(_tag, sRequestPath);
156
156
157
- WSJCppLightWebHttpResponse resp(pRequest->getSockFd());
157
+ WsjcppLightWebHttpResponse resp(pRequest->getSockFd());
158
158
if (sRequestPath == "/custom" || sRequestPath == "/custom/") {
159
159
resp.cacheSec(60).ok().sendText(
160
160
"<h1>This is custom</h1>"
@@ -175,10 +175,10 @@ bool HttpHandlerCustom::handle(const std::string &sWorkerId, WSJCppLightWebHttpR
175
175
Example init, add handler and start server
176
176
__ order is important! Server will call canHandle & handle in same order as addHandler called__
177
177
```
178
- WSJCppLightWebServer httpServer;
178
+ WsjcppLightWebServer httpServer;
179
179
httpServer.setPort(1234);
180
180
httpServer.setMaxWorkers(1);
181
- httpServer.addHandler((WSJCppLightWebHttpHandlerBase *)new HttpHandlerCustom());
182
- httpServer.addHandler((WSJCppLightWebHttpHandlerBase *)new WSJCppLightWebHttpHandlerRewriteFolder ("/", "./web"));
181
+ httpServer.addHandler((WsjcppLightWebHttpHandlerBase *)new HttpHandlerCustom());
182
+ httpServer.addHandler((WsjcppLightWebHttpHandlerBase *)new WsjcppLightWebHttpHandlerRewriteFolder ("/", "./web"));
183
183
httpServer.startSync(); // this method will be hold current thread, if you with you can call just start/stop command
184
184
```
0 commit comments