flyingeinstein / Restfully

Arduino library for making Rest compliant APIs on the ESP8266 with embedded Uri arguments
MIT License
9 stars 2 forks source link

Older version in the library manager #7

Open shannon-nii opened 3 years ago

shannon-nii commented 3 years ago

Just a heads up, when you download the current Arduino version and add restfully via the library manager, it will download an older version and either of the two examples given here on github will not work. Not sure how much you can influence what the library manager contains. Thanks for the great library in any case, makes things a lot easier 👍

guru-florida commented 3 years ago

Thanks! I will take a look. I can push an update but I will need to review the code first.

guru-florida commented 3 years ago

FYI There is actually a new version in branch feature/KISS that needs to be released. The current interface is easy...until you have an error then it spews a bunch of GCC template errors. The code in-behind the API is very complex and in the end I found it inflexible even for my needs. The KISS version changes the interface up a bit. It's maybe not quite as simple as the current API using method chaining but it is far simpler code in-behind and doesn't generate unreadable errors. Even still KISS is 10x simpler to use after you experience even 1 template error (with current). lol.

I don't have the docs updated but the main difference is it overloads the / operator to provide URL path parsing. Think similar to C++ << streams. So an example would be something like:

int user_id;
if(request / "api" / "users" / &user_id / "details") {
     // return user details with user ID in user_id variable
     // ...
}

The return value of any / operator is a URL parser state object which can be casted to bool (true if URL matches). Instead of just using if(...) to test for URL match you can also store the result at any point in the URL path in a variable and branch out to match different URL paths. So parsing is efficient! But this also means you can do any custom code at any point in your matching...such as resolving the user object before the final endpoint handler runs. You can also match to an endpoint, fail out, and have it recover at some earlier point and attempt another branch.

raffaeler commented 8 months ago

Any updates on this? Please let us know if you are continuiing the maintenance or not, otherwise we can find an adeguate replacement. Thanks