├── test
├── pages
│ └── test.html
├── CMakeLists.txt
├── TestTypeController.cpp
├── HttpHelper.h
├── HttpHelper.cpp
├── TestPageController.h
├── TestWebServer.h
├── TestBaseController.h
├── main.cpp
├── TestApiController.h
├── HttpClient.h
├── TestTypeController.h
├── TestWebServer.cpp
├── TestPageController.cpp
├── TestBaseController.cpp
├── TestApiController.cpp
└── HttpClient.cpp
├── CMakeLists.txt
├── examples
├── example3.cpp
├── CMakeLists.txt
├── web
│ ├── index.html
│ ├── page_a.html
│ └── page_b.html
├── example2.cpp
└── example1.cpp
├── .gitignore
├── appveyor.yml
├── src
├── PageController.h
├── ApiController.h
├── Response.h
├── PageController.cpp
├── IWebController.h
├── ApiController.cpp
├── Response.cpp
├── Request.h
├── WebServer.h
├── Request.cpp
├── TypeController.h
└── WebServer.cpp
├── .travis.yml
├── dependency
└── UnitTest
│ ├── UnitTest.cpp
│ ├── UnitTest.h
│ └── termcolor.h
├── README.md
└── LICENSE
/test/pages/test.html:
--------------------------------------------------------------------------------
1 |
Test
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FragJage/MongooseCpp/HEAD/CMakeLists.txt
--------------------------------------------------------------------------------
/examples/example3.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FragJage/MongooseCpp/HEAD/examples/example3.cpp
--------------------------------------------------------------------------------
/test/CMakeLists.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FragJage/MongooseCpp/HEAD/test/CMakeLists.txt
--------------------------------------------------------------------------------
/examples/CMakeLists.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FragJage/MongooseCpp/HEAD/examples/CMakeLists.txt
--------------------------------------------------------------------------------
/test/TestTypeController.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FragJage/MongooseCpp/HEAD/test/TestTypeController.cpp
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | obj
2 | bin
3 | *.out
4 | *.layout
5 | *.depend
6 | *.dir
7 | .vs
8 | *.VC.*
9 | *.filter
10 | *.user
11 |
--------------------------------------------------------------------------------
/examples/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Index
4 | Page A
5 | Page B
6 |
7 |
--------------------------------------------------------------------------------
/examples/web/page_a.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Page A
4 | Page B
5 | Index
6 |
7 |
--------------------------------------------------------------------------------
/examples/web/page_b.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Page B
4 | Page A
5 | Index
6 |
7 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | branches:
2 | only:
3 | - master
4 |
5 | image: Visual Studio 2015
6 |
7 | platform: Win32
8 | configuration: Release
9 |
10 | build:
11 | project: builds\msvc\MongooseCpp.sln
12 |
13 | after_build:
14 | - builds\msvc\bin\unittest.exe
--------------------------------------------------------------------------------
/test/HttpHelper.h:
--------------------------------------------------------------------------------
1 | #ifndef HTTPHELPER_H
2 | #define HTTPHELPER_H
3 |
4 | #include "WebServer.h"
5 | #include "HttpClient.h"
6 |
7 | class HttpHelper
8 | {
9 | public:
10 | static bool WaitResponse(MongooseCpp::WebServer& server, HttpClient& client);
11 | };
12 |
13 | #endif // HTTPHELPER_H
14 |
--------------------------------------------------------------------------------
/test/HttpHelper.cpp:
--------------------------------------------------------------------------------
1 | #include "HttpHelper.h"
2 |
3 | bool HttpHelper::WaitResponse(MongooseCpp::WebServer& server, HttpClient& client)
4 | {
5 | int i, imax=25;
6 | for(i=0; i
2 | #include "PageController.h"
3 | #include "WebServer.h"
4 | #include "HttpClient.h"
5 | #include "HttpHelper.h"
6 | #include "UnitTest/UnitTest.h"
7 |
8 | using namespace std;
9 |
10 | class TestPageController : public TestClass
11 | {
12 | public:
13 | TestPageController();
14 | ~TestPageController();
15 |
16 | bool WithDirListing();
17 | bool WithoutDirListing();
18 | bool SimplePage();
19 | bool Error404();
20 | };
21 |
--------------------------------------------------------------------------------
/src/PageController.h:
--------------------------------------------------------------------------------
1 | #ifndef PAGECONTROLLER_H
2 | #define PAGECONTROLLER_H
3 |
4 | #include
5 | #include "IWebController.h"
6 | #include "mongoose/mongoose.h"
7 |
8 | namespace MongooseCpp {
9 |
10 | class PageController : public IWebController
11 | {
12 | public:
13 | PageController(const std::string& documentRoot, bool enableDirectoryListing);
14 | virtual ~PageController();
15 | bool Process(Request& request, Response& response);
16 |
17 | private:
18 | std::string m_DocumentRoot;
19 | bool m_EnableDirectoryListing;
20 | };
21 |
22 | }
23 |
24 | #endif // PAGECONTROLLER_H
25 |
--------------------------------------------------------------------------------
/src/ApiController.h:
--------------------------------------------------------------------------------
1 | #ifndef APICONTROLLER_H
2 | #define APICONTROLLER_H
3 |
4 | #include "IWebController.h"
5 |
6 | namespace MongooseCpp {
7 |
8 | class ApiController : public IWebController
9 | {
10 | public:
11 | ApiController();
12 | virtual ~ApiController();
13 | bool Process(Request& request, Response& response);
14 | virtual bool Get(Request& request, Response& response);
15 | virtual bool Put(Request& request, Response& response);
16 | virtual bool Post(Request& request, Response& response);
17 | virtual bool Delete(Request& request, Response& response);
18 | };
19 |
20 | }
21 |
22 | #endif // APICONTROLLER_H
23 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: cpp
2 | compiler: gcc
3 |
4 | env:
5 | global:
6 | - CXXCOMPILER=g++-4.9
7 | - CCCOMPILER=gcc-4.9
8 |
9 | addons:
10 | apt:
11 | sources: ['ubuntu-toolchain-r-test']
12 | packages: ['gcc-4.9','g++-4.9','valgrind']
13 |
14 | install:
15 | - sudo pip install -U "cpp-coveralls"
16 |
17 | script:
18 | - cmake . -G"Unix Makefiles" -DCMAKE_CC_COMPILER=$(which $CCCOMPILER) -DCMAKE_CXX_COMPILER=$(which $CXXCOMPILER)
19 | - make
20 | - ./test/bin/unittest
21 |
22 | after_success:
23 | ls /home/travis/build/FragJage/MongooseCpp/test/CMakeFiles/unittest.dir;
24 | coveralls --include src --gcov-options '\-lp' --gcov 'gcov-4.9';
25 | valgrind --error-exitcode=1 --leak-check=full ./test/bin/unittest;
26 |
--------------------------------------------------------------------------------
/test/TestWebServer.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include "IWebController.h"
3 | #include "WebServer.h"
4 | #include "UnitTest/UnitTest.h"
5 |
6 | using namespace std;
7 |
8 | class EmptyController : public MongooseCpp::IWebController
9 | {
10 | public:
11 | EmptyController();
12 | ~EmptyController();
13 | bool Process(MongooseCpp::Request& request, MongooseCpp::Response& response);
14 | };
15 |
16 | class TestWebServer : public TestClass
17 | {
18 | public:
19 | TestWebServer();
20 | ~TestWebServer();
21 |
22 | bool IncorrectStar();
23 | bool MissingChar();
24 | bool OptionalAtEnd();
25 | bool StartAndStop();
26 |
27 | private:
28 | EmptyController emptyCtrl;
29 | };
30 |
--------------------------------------------------------------------------------
/test/TestBaseController.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include "IWebController.h"
3 | #include "WebServer.h"
4 | #include "UnitTest/UnitTest.h"
5 | #include "HttpClient.h"
6 |
7 | using namespace std;
8 |
9 | class BaseController : public MongooseCpp::IWebController
10 | {
11 | public:
12 | BaseController();
13 | ~BaseController();
14 | bool Process(MongooseCpp::Request& request, MongooseCpp::Response& response);
15 | };
16 |
17 | class TestBaseController : public TestClass
18 | {
19 | public:
20 | TestBaseController();
21 | ~TestBaseController();
22 |
23 | bool ReadHttpMethod();
24 | bool ReadParameters();
25 | bool Error404();
26 |
27 | private:
28 | MongooseCpp::WebServer server;
29 | HttpClient client;
30 | BaseController myBaseCtrl;
31 | };
32 |
--------------------------------------------------------------------------------
/test/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "TestWebServer.h"
3 | #include "TestBaseController.h"
4 | #include "TestPageController.h"
5 | #include "TestApiController.h"
6 | #include "TestTypeController.h"
7 |
8 |
9 | using namespace std;
10 |
11 | int main(void)
12 | {
13 | int ret = 0;
14 | UnitTest unitTest;
15 |
16 |
17 | try
18 | {
19 | unitTest.addTestClass(new TestWebServer());
20 | unitTest.addTestClass(new TestBaseController());
21 | unitTest.addTestClass(new TestPageController());
22 | unitTest.addTestClass(new TestApiController());
23 | unitTest.addTestClass(new TestTypeController());
24 | }
25 | catch(const exception &e)
26 | {
27 | unitTest.displayError(e.what());
28 | ret = -1;
29 | }
30 |
31 | if(ret!=-1)
32 | if(!unitTest.run()) ret = 1;
33 |
34 | return ret;
35 | }
36 |
--------------------------------------------------------------------------------
/src/Response.h:
--------------------------------------------------------------------------------
1 | #ifndef RESPONSE_H
2 | #define RESPONSE_H
3 |
4 | #include
5 | #include