Skip to content

Commit

Permalink
Removing test logging, Windows support (might come back in the future…
Browse files Browse the repository at this point in the history
…) and updating the README.md file
  • Loading branch information
JustAn0therDev committed Oct 3, 2021
1 parent 69f3f7d commit 039bbfc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 50 deletions.
14 changes: 0 additions & 14 deletions HTTP/http_request_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,6 @@ void HttpRequestHandler::HandleGet(const BlackMarlin& p_black_marlin, const http

const auto& value = p_black_marlin.Get(p_req.get_param_value("key"));

char* log_message = static_cast<char *>(malloc(sizeof(char) * 200));

log_message = strcpy(log_message, "Get route. Key: ");

log_message = strcat(log_message, p_req.get_param_value("key").c_str());

log_message = strcat(log_message, " - Error: ");

log_message = strcat(log_message, "New testing OK.");

this->m_logger.Log(log_message);

free(log_message);

if (std::empty(value))
{
p_res.status = static_cast<int>(StatusCode::kNoContent);
Expand Down
17 changes: 1 addition & 16 deletions PathHandler/path_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,16 @@
#include <sstream>
#include <iostream>

#if _WIN32 || _WIN64

#include <Windows.h>
#define PATH_DELIMETER '\\'

#else

#include <unistd.h>
#include <climits>
#define PATH_DELIMETER '/'

#endif

std::string PathHandler::GetThisExecutingBinaryFullPath()
{
bool found_binary = false;
std::string full_path, path_part, filename_part_to_look_for;

#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) || defined(WIN64)

char path_buffer[MAX_PATH] = { '\0' };
filename_part_to_look_for = "blackmarlin.exe";
GetModuleFileName(NULL, path_buffer, MAX_PATH);

#elif defined(linux) || defined(__linux) || defined(__linux__)
#if defined(linux) || defined(__linux) || defined(__linux__)

char path_buffer[PATH_MAX] = { '\0' };
filename_part_to_look_for = "blackmarlin";
Expand Down
29 changes: 9 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ This also allows servers in an architecture that uses Load Balancing to share ke


## Features:
- It is currently using an `std::unordered_map` to store the keys and values;
- The main library is covered by unit tests with [catchv2](https://github.com/catchorg/Catch2);
- REST API interface for HTTP methods written on top of the main library with [cpp-httplib](https://github.com/yhirose/cpp-httplib);
- Integration tests are made to insure that every route is working (the integration tests will be in the version control of this repository in the near future);
- Performance profiling and memory leak checks;
- Allows custom response headers;
- Compatible with Windows and Linux servers (check below in the "how to compile" and in the "releases" tab for more information on Windows releases).
- Integration tests are made to insure that every route is working as intended. This repository has a Postman collection with a really big JSON file you can use to test its performance;
- Allows custom response headers and port.

## Usage:
The program runs on port **7000** by default. You can test it by making a GET request to "http://127.0.0.1:7000/count" with your program running, for example. It should return `200 - OK` with `0` in the response body (assuming you didn't have any keys cached by Black Marlin prior to calling this route). The only thing you have to do to integrate it with your application is make HTTP requests and handle its responses.
Expand All @@ -30,13 +27,7 @@ If you want Black Marlin to be available via a port of your choice, you can run

`./blackmarlin 8534`

or

`./blackmarlin.exe 8534`

depending on the release you're using.

Note that if the port argument is an invalid value the program will not run and an error message will be printed to STDOUT.
Note that if the port argument is an invalid value the program will not run and an error message will be written to STDOUT.

--------------------------

Expand Down Expand Up @@ -115,7 +106,8 @@ To disable this behavior just delete/remove the file mentioned and the server wi
---------------------------

### Logs:
Everytime an error occurs it is written to a file called `bm_logs.txt` (its created if it doesn't already exist in the same directory as the program).
Everytime an error occurs it is written to a file called `bm_logs.txt` (it is created if it doesn't already exist in the same directory). Every log message will have the following format:

`{Year}-{Month}-{Day} {Hour}:{Minute}:{Second} - {ErrorMessage}`

---------------------------
Expand All @@ -126,8 +118,8 @@ Everytime an error occurs it is written to a file called `bm_logs.txt` (its crea
---------------------------

### Sidenotes:
- This program does NOT support any other operating system except for Windows (last release) and Linux (current and past releases); If you try to run it on MacOS for example, the program will not run.
- **There is a pre-release available for testing!**
- This program does NOT officially support any other operating system except for Linux. If you try to run it on a Mac OS for example, the program will not run.
- **The first official release is available!**

---------------------------

Expand All @@ -137,13 +129,10 @@ Everytime an error occurs it is written to a file called `bm_logs.txt` (its crea
Feel free to open issues and fork as you feel like it. I'll be happy to help in any case.

### How to compile:
The program can be compiled in any way as long as it supports threads (expiring keys in the main library and `cpphttplib`) and the C++17 standard. The recommended way to compile the program is by using CMake. It is already configured in the repo and can be done both on Windows and Linux.

As of now, the current Windows version does not support the OpenSSL library and therefore is not available in the current release.
After giving it some thought, maybe there is no need for Windows support at all given the current state of the Web and the amount of servers using only Linux. **This is still being reviewed and should not be consired true for all subsequent releases**.
The program can be compiled in any way as long as it supports threads (expiring keys in the main library and `cpphttplib`), is targeting the C++17 standard and includes OpenSSL. The recommended way to compile the program is using CMake. It is already configured in the repo and can be done both on Windows and Linux.

### How to test:
`cd` to `unittests` directory and run the `run_unittests.sh` bash file. **Any other modules to be tested have to be added to the file mentioned**.
`cd` to `unittests` directory and run the `run_unittests.sh` bash file. **Any other modules to be tested have to be added to the mentioned file**.

### Guidelines:
- Please follow the code's pattern; keeping the code looking the same everywhere in the program makes it easier to change stuff.

0 comments on commit 039bbfc

Please sign in to comment.