GXTX / YACardEmu

Software emulator for Sanwa CRP-1231BR-10 / CRP-1231LR-10NAB / CR-S31R-10HS3 card readers.
GNU General Public License v2.0
33 stars 10 forks source link

Some resemblance of a REST API #10

Closed hjri closed 2 years ago

hjri commented 2 years ago

Here you go, some resemblance of a proper REST API:

Endpoints:

Future thoughts:

P.S. I'm a complete noob in C(++), excuse the bad code/copypaste. P.P.S. DB9 breakout adapters finally arrived, will be testing emulator this weekend hopefully.

GXTX commented 2 years ago

I'm not entirely sold on having them separated (for example multiple get commands should be handled by the same lambda), but I don't think it's worth bike shedding over.

Something like this.

svr.Post(R"(/methods/(\w+))", [&](const httplib::Request &req, httplib::Response &res) {
        auto match = req.matches[1];
        std::string str(match);
        spdlog::info("Method: {}", str);
}

I'll make the assumption that it works and merge.

RE: Hardware tests, be sure to read the "new" readme, I've added baud speed support and parity to the config as well.

Thanks!