Skip to content

Commit 6f22a44

Browse files
authored
Merge pull request #117 from coding-cpp/fix/110
Fix/110
2 parents 332160e + 99fdcd5 commit 6f22a44

File tree

20 files changed

+72
-171
lines changed

20 files changed

+72
-171
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
[submodule "lib/zippuccino"]
1414
path = lib/zippuccino
1515
url = git@github.com:coding-cpp/zippuccino.git
16+
[submodule "lib/mochios"]
17+
path = lib/mochios
18+
url = git@github.com:coding-cpp/mochios

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ target_include_directories(server
4040
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/brewtils/include>
4141
$<INSTALL_INTERFACE:lib/zippuccino/include>
4242
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/zippuccino/include>
43+
$<INSTALL_INTERFACE:lib/mochios/include>
44+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/mochios/include>
4345
)

assets/github/build.png

26.9 KB
Loading

assets/github/start.png

-14.7 KB
Loading

example/main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ void about(Request &req, Response &res) {
5757
response["submodules"][4]["location"] = "lib/zippuccino";
5858
response["submodules"][4]["name"] = "Zippuccino";
5959

60+
json::object mochios;
61+
mochios["repository"] = "https://github.com/coding-cpp/mochios";
62+
mochios["work"] = "HTTP request library for C++";
63+
mochios["location"] = "lib/mochios";
64+
mochios["name"] = "Mochios";
65+
response["submodules"].push_back(mochios);
66+
6067
res.status(STATUS_CODE::OK).json(response).end();
6168
return;
6269
}

include/expresso/core/router.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class Router {
3737
expresso::messages::Response &response);
3838
std::map<std::string, void (*)(expresso::messages::Request &request,
3939
expresso::messages::Response &response)> &
40-
fetchMapFromMethod(expresso::enums::method method);
41-
void addRoute(expresso::enums::method method, std::string path,
40+
fetchMapFromMethod(mochios::enums::method method);
41+
void addRoute(mochios::enums::method method, std::string path,
4242
void (*handler)(expresso::messages::Request &request,
4343
expresso::messages::Response &response));
4444

include/expresso/enums/method.h

Lines changed: 0 additions & 26 deletions
This file was deleted.

include/expresso/messages/cookie.h

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,16 @@
11
#pragma once
22

3-
#include <string>
4-
5-
#include <brewtils/url.h>
3+
#include <mochios/messages/cookie.h>
64

75
namespace expresso {
86

97
namespace messages {
108

11-
class Cookie {
9+
class Cookie : public mochios::messages::Cookie {
1210
public:
13-
bool secure;
14-
bool httpOnly;
15-
bool partitioned;
16-
17-
std::string name;
18-
std::string value;
19-
std::string domain;
20-
std::string path;
21-
std::string expires;
22-
std::string maxAge;
23-
std::string sameSite;
24-
2511
Cookie();
12+
Cookie(const std::string &data);
2613
~Cookie();
27-
28-
std::string serialize();
2914
};
3015

3116
} // namespace messages

include/expresso/messages/request.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
11
#pragma once
22

3+
#include <mochios/messages/request.h>
4+
35
#include <expresso/messages/response.h>
46

57
namespace expresso {
68

79
namespace messages {
810

9-
class Request {
11+
class Request : public mochios::messages::Request {
1012
private:
1113
public:
12-
Request();
14+
Request(const std::string &path);
1315
~Request();
1416

1517
bool xhr;
1618
int contentLength;
1719

1820
std::string host;
1921
std::string hostname;
20-
expresso::enums::method method;
21-
std::string path;
2222
std::string httpVersion;
2323

2424
// tempPath used internally for referencing. DO NOT USE IT! Use `path`
2525
// instead.
2626
std::string tempPath;
27-
28-
json::object body;
29-
std::vector<Cookie *> cookies;
30-
std::map<std::string, std::string> headers;
31-
std::map<std::string, std::string> params;
32-
std::map<std::string, std::string> queries;
27+
std::vector<expresso::messages::Cookie *> cookies;
3328

3429
expresso::messages::Response *res;
3530

36-
void print();
31+
void print() override;
3732
};
3833

3934
} // namespace messages

include/expresso/messages/response.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,25 @@
77
#include <brewtils/string.h>
88
#include <brewtils/sys.h>
99
#include <json/object.h>
10+
#include <mochios/enums/method.h>
11+
#include <mochios/messages/response.h>
1012
#include <zippuccino/zipper.h>
1113

12-
#include <expresso/enums/method.h>
1314
#include <expresso/enums/status_code.h>
1415
#include <expresso/messages/cookie.h>
1516

1617
namespace expresso {
1718

1819
namespace messages {
1920

20-
class Response {
21+
class Response : public mochios::messages::Response {
2122
private:
2223
bool hasEnded;
2324

2425
int socket;
25-
expresso::enums::STATUS_CODE statusCode;
2626

2727
std::string message;
2828
std::vector<Cookie *> cookies;
29-
std::map<std::string, std::string> headers;
3029

3130
void sendToClient();
3231
void sendHeaders();
@@ -51,7 +50,7 @@ class Response {
5150
void sendInvalidRange();
5251

5352
void end();
54-
void print();
53+
void print() override;
5554
};
5655

5756
} // namespace messages

0 commit comments

Comments
 (0)