Skip to content

Commit b3aecca

Browse files
committed
feat(print-version): Added feature to print kleinsHTTP Version
1 parent f86b15f commit b3aecca

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

example.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ int main()
66
std::cout << "Hello world!" << std::endl;
77

88
kleins::httpServer server;
9+
10+
server.printVersion();
11+
912
server.addSocket(new kleins::tcpSocket("0.0.0.0",8080));
1013
server.addSocket(new kleins::sslSocket("0.0.0.0",4433,"./example.crt","./example.key"));
1114

makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ TGTDBG=target/debug
2424

2525
LIBS= -lssl -lcrypto -lpthread
2626

27-
BUILDPARAMS=g++ -std=c++17 $^ -O2 -o $@ -c -fPIC
28-
BUILDPARAMS_DBG=g++ -std=c++17 $^ -ggdb -o $@ -c -fPIC
27+
VERSION=0.1.2
2928

30-
VERSION=0.1.1
29+
BUILDPARAMS=g++ -std=c++17 -D BUILD_VERSION=\"$(VERSION)-release\" $^ -O2 -o $@ -c -fPIC
30+
BUILDPARAMS_DBG=g++ -std=c++17 -D BUILD_VERSION=\"$(VERSION)-debug\" $^ -ggdb -o $@ -c -fPIC
3131

3232
debug: $(TGTDBG)/libkleinsHTTP.so $(TGTDBG)/kleinsHTTP.h $(TGTDBG)/kleinsHTTP.a
3333

source/httpServer/httpServer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,8 @@ void kleins::httpServer::serveDirectory(const std::string& baseuri, const std::s
213213
serve(filepath.substr(path.length()), p.path());
214214
}
215215
}
216+
}
217+
218+
void kleins::httpServer::printVersion() {
219+
std::cout << "kleinsHTTP Build: " << BUILD_VERSION << std::endl;
216220
}

source/httpServer/httpServer.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#include "../packet/packet.h"
1111
#include "../socketBase/socketBase.h"
1212

13+
#ifndef BUILD_VERSION
14+
#define BUILD_VERSION "UNKNOWN"
15+
#endif
16+
1317
namespace kleins {
1418

1519
typedef enum httpMethod { GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH } httpMethod;
@@ -104,6 +108,12 @@ class httpServer {
104108
* @return false
105109
*/
106110
bool addSocket(socketBase* socket);
111+
112+
/**
113+
* @brief Print the version of kleinsHTTP to the stdout
114+
*
115+
*/
116+
void printVersion();
107117
};
108118

109119
} // namespace kleins

0 commit comments

Comments
 (0)