Closed hjri closed 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!
Here you go, some resemblance of a proper REST API:
/api/v1
Endpoints:
/dispenser
- POST sets it to full, DELETE to empty, responds with plaintext "empty" or "full", GET yields current status/insertedCard
- POST sets it to card present, optionally?cardname=...
argument to set loaded card, DELETE sets it to card empty (doesn't update card name), GET yields current status (both cardname and inserted status)/cards
- same as old/actions?list
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.