Skip to content

Commit ec6effa

Browse files
committed
Updated wsjcpp-core to v0.1.1
1 parent 133fbc3 commit ec6effa

26 files changed

+550
-429
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ RewriteRule . index.html
4646

4747
Contains base handler:
4848
```
49-
WSJCppLightWebHttpHandlerRewriteFolder(sPrefixPath, sDirPath)
49+
WsjcppLightWebHttpHandlerRewriteFolder(sPrefixPath, sDirPath)
5050
```
5151
Where
5252
* sPrefixPath - like "/app1/" -> "http://localhost:1234/app1/"
@@ -61,10 +61,10 @@ Example init, add handler and start server
6161
#include <wsjcpp_light_web_http_handler_rewrite_folder.h>
6262
6363
...
64-
WSJCppLightWebServer httpServer;
64+
WsjcppLightWebServer httpServer;
6565
httpServer.setPort(1234);
6666
httpServer.setMaxWorkers(1);
67-
httpServer.addHandler((WSJCppLightWebHttpHandlerBase *)new WSJCppLightWebHttpHandlerRewriteFolder("/app1/", "./web"));
67+
httpServer.addHandler((WsjcppLightWebHttpHandlerBase *)new WsjcppLightWebHttpHandlerRewriteFolder("/app1/", "./web"));
6868
httpServer.startSync(); // this method will be hold current thread, if you with you can call just start/stop command
6969
```
7070

@@ -74,7 +74,7 @@ After compile and start will be available on `http://localhost:1234/app1/`
7474

7575
Contains base handler:
7676
```
77-
WSJCppLightWebHttpHandlerWebFolder(sPrefixPath, sDirPath)
77+
WsjcppLightWebHttpHandlerWebFolder(sPrefixPath, sDirPath)
7878
```
7979

8080
Where
@@ -88,10 +88,10 @@ Example init, add handler and start server
8888
#include <wsjcpp_light_web_http_handler_web_folder.h>
8989
9090
...
91-
WSJCppLightWebServer httpServer;
91+
WsjcppLightWebServer httpServer;
9292
httpServer.setPort(1234);
9393
httpServer.setMaxWorkers(1);
94-
httpServer.addHandler((WSJCppLightWebHttpHandlerBase *)new WSJCppLightWebHttpHandlerWebFolder("/app2/", "./web"));
94+
httpServer.addHandler((WsjcppLightWebHttpHandlerBase *)new WsjcppLightWebHttpHandlerWebFolder("/app2/", "./web"));
9595
httpServer.startSync(); // this method will be hold current thread, if you with you can call just start/stop command
9696
```
9797

@@ -108,11 +108,11 @@ header-file `http_handler_custom.h`:
108108
109109
#include <wsjcpp_light_web_server.h>
110110
111-
class HttpHandlerCustom : WSJCppLightWebHttpHandlerBase {
111+
class HttpHandlerCustom : WsjcppLightWebHttpHandlerBase {
112112
public:
113113
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);
116116
117117
private:
118118
std::string TAG;
@@ -128,13 +128,13 @@ source-file `http_handler_custom.cpp`:
128128
// ----------------------------------------------------------------------
129129
130130
HttpHandlerCustom::HttpHandlerCustom()
131-
: WSJCppLightWebHttpHandlerBase("custom") {
131+
: WsjcppLightWebHttpHandlerBase("custom") {
132132
TAG = "HttpHandlerCustom";
133133
}
134134
135135
// ----------------------------------------------------------------------
136136
137-
bool HttpHandlerCustom::canHandle(const std::string &sWorkerId, WSJCppLightWebHttpRequest *pRequest) {
137+
bool HttpHandlerCustom::canHandle(const std::string &sWorkerId, WsjcppLightWebHttpRequest *pRequest) {
138138
std::string _tag = TAG + "-" + sWorkerId;
139139
std::string sRequestPath = pRequest->getRequestPath();
140140
@@ -149,12 +149,12 @@ bool HttpHandlerCustom::canHandle(const std::string &sWorkerId, WSJCppLightWebHt
149149
150150
// ----------------------------------------------------------------------
151151
152-
bool HttpHandlerCustom::handle(const std::string &sWorkerId, WSJCppLightWebHttpRequest *pRequest) {
152+
bool HttpHandlerCustom::handle(const std::string &sWorkerId, WsjcppLightWebHttpRequest *pRequest) {
153153
std::string _tag = TAG + "-" + sWorkerId;
154154
std::string sRequestPath = pRequest->getRequestPath();
155-
// WSJCppLog::warn(_tag, sRequestPath);
155+
// WsjcppLog::warn(_tag, sRequestPath);
156156
157-
WSJCppLightWebHttpResponse resp(pRequest->getSockFd());
157+
WsjcppLightWebHttpResponse resp(pRequest->getSockFd());
158158
if (sRequestPath == "/custom" || sRequestPath == "/custom/") {
159159
resp.cacheSec(60).ok().sendText(
160160
"<h1>This is custom</h1>"
@@ -175,10 +175,10 @@ bool HttpHandlerCustom::handle(const std::string &sWorkerId, WSJCppLightWebHttpR
175175
Example init, add handler and start server
176176
__order is important! Server will call canHandle & handle in same order as addHandler called__
177177
```
178-
WSJCppLightWebServer httpServer;
178+
WsjcppLightWebServer httpServer;
179179
httpServer.setPort(1234);
180180
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"));
183183
httpServer.startSync(); // this method will be hold current thread, if you with you can call just start/stop command
184184
```

scripts.wsjcpp/generate.WsjcppLightWebHttpHandler

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ concat content_header "#ifndef " ifndef_header "
3636

3737
#include <wsjcpp_light_web_server.h>
3838

39-
class " class_name " : public WSJCppLightWebHttpHandlerBase {
39+
class " class_name " : public WsjcppLightWebHttpHandlerBase {
4040
public:
4141
" class_name "();
42-
virtual bool canHandle(const std::string &sWorkerId, WSJCppLightWebHttpRequest *pRequest);
43-
virtual bool handle(const std::string &sWorkerId, WSJCppLightWebHttpRequest *pRequest);
42+
virtual bool canHandle(const std::string &sWorkerId, WsjcppLightWebHttpRequest *pRequest);
43+
virtual bool handle(const std::string &sWorkerId, WsjcppLightWebHttpRequest *pRequest);
4444

4545
private:
4646
std::string TAG;
@@ -58,29 +58,29 @@ concat content_source "
5858
// " class_name "
5959

6060
" class_name "::" class_name "()
61-
: WSJCppLightWebHttpHandlerBase(\"" http_handler_name "\") {
61+
: WsjcppLightWebHttpHandlerBase(\"" http_handler_name "\") {
6262
TAG = \"" class_name "\";
6363
}
6464

6565
// ---------------------------------------------------------------------
6666

67-
bool " class_name "::canHandle(const std::string &sWorkerId, WSJCppLightWebHttpRequest *pRequest) {
67+
bool " class_name "::canHandle(const std::string &sWorkerId, WsjcppLightWebHttpRequest *pRequest) {
6868
std::string _tag = TAG + \"-\" + sWorkerId;
6969
std::string sRequestPath = pRequest->getRequestPath();
70-
WSJCppLog::warn(_tag, \"canHandle: \" + sRequestPath);
70+
WsjcppLog::warn(_tag, \"canHandle: \" + sRequestPath);
7171

7272
// TODO
73-
WSJCppLog::err(TAG, \"Not implemented\");
73+
WsjcppLog::err(TAG, \"Not implemented\");
7474
return false;
7575
}
7676

7777
// ---------------------------------------------------------------------
7878

79-
bool " class_name "::handle(const std::string &sWorkerId, WSJCppLightWebHttpRequest *pRequest) {
79+
bool " class_name "::handle(const std::string &sWorkerId, WsjcppLightWebHttpRequest *pRequest) {
8080
std::string _tag = TAG + \"-\" + sWorkerId;
8181
std::string sRequestPath = pRequest->getRequestPath();
82-
WSJCppLog::warn(_tag, sRequestPath);
83-
WSJCppLightWebHttpResponse resp(pRequest->getSockFd());
82+
WsjcppLog::warn(_tag, sRequestPath);
83+
WsjcppLightWebHttpResponse resp(pRequest->getSockFd());
8484
resp.noCache().notImplemented().sendEmpty();
8585
return true;
8686
}

src.wsjcpp/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Automaticly generated by [email protected]
22
cmake_minimum_required(VERSION 3.0)
33

4-
add_definitions(-DWSJCPP_VERSION="v0.0.1")
4+
add_definitions(-DWSJCPP_VERSION="v0.1.0")
55
add_definitions(-DWSJCPP_NAME="wsjcpp-light-web-server")
66

77
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -17,7 +17,7 @@ set (WSJCPP_SOURCES "")
1717
find_package(Threads REQUIRED)
1818
list (APPEND WSJCPP_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
1919

20-
# wsjcpp-core:v0.0.7
20+
# wsjcpp-core:v0.1.1
2121
list (APPEND WSJCPP_INCLUDE_DIRS "./src.wsjcpp/wsjcpp_core/")
2222
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp_core/wsjcpp_core.cpp")
2323
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp_core/wsjcpp_core.h")

src.wsjcpp/wsjcpp_core/wsjcpp.hold.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_cxx_standard: 11
33
cmake_minimum_required: 3.0
44

55
name: wsjcpp-core
6-
version: v0.0.7
6+
version: v0.1.1
77
description: Basic Utils for wsjcpp
88
issues: https://github.com/wsjcpp/wsjcpp-core/issues
99
repositories:
@@ -62,3 +62,9 @@ unit-tests:
6262
description: "Test split function"
6363
- name: "CreateEmptyFile"
6464
description: "Test create empty file"
65+
- name: "ReadFileToBuffer"
66+
description: "test for readFileToBuffer"
67+
- name: "Join"
68+
description: "Test join function"
69+
- name: "getHumanSizeBytes"
70+
description: "Test function get human size in bytes"

0 commit comments

Comments
 (0)