illuminated-g / lv-http-server

HTTP Server implementation in LabVIEW. Utilizes IG TCP Streams and provides mechanisms akin to Web Services.
MIT License
9 stars 0 forks source link

minimal restful server example #14

Open EastEriq opened 1 year ago

EastEriq commented 1 year ago

I'm looking into inserting a minimal portable restful interface into a future project. Without much concern for security (isolated lan), I'd be even happy with just the capability of retrieving the client query string (e.g. page?key1=value&key2=value...), supplied for further parsing by the application. Bonuses of course would be some query parsing utility, or even the option of a callback VI receiving the values. From a tour of the Tests I got the impression that the functionality should be there, but couldn't figure out a way. Could you point me to some example? TIA

negentropicdev commented 1 year ago

@EastEriq I'm going to create a simpler example for using query parameters. If you want to share any more details about your application setup and what it wants to do based on the query parameters I can make a more purposed example.

negentropicdev commented 1 year ago

@EastEriq Take a look at the new Test Query Parameters example and let me know if that is clear enough for accessing and looking up query parameters.

EastEriq commented 1 year ago

Yes, thanks, much appreciated. I originally eyed Query Auth as you suggested, which is also ?& formed, but i didn't descend into its mechanics. I suspected that I needed to put together a specific handler class and register it, but I didn't know how. Query Parameters now clarifies it. As for my application, which is supposed to include a REST server interface to the business logic, I guess that I will have to decompose the Do Request VI, and generate an user event/ enqueue the target URI payload in some queue which is polled for new elements in another thread, or something along that lines. The general idea is to receive query commands on the server, dispatch them to instruments, and return replies to the client. The important part of it, for which your server looks great, is to get the query data into LabVIEW dataspace. From there on, how to process the query will be application specific architecture. I'll pursue further the idea in the next days, will eventually come back if I have further questions/issues/ideas. Thanks!

negentropicdev commented 1 year ago

I'll work on one more example of integrating with an application that is doing other stuff. You'll have to decide if you want the response to the client to include confirmation of whether the whole request was handled successfully, or just that it was received properly. In the former, there would typically need to be some assurance that the request can complete in a timely manner while in the latter there might be some polling mechanism on the client that continually retrieves status.

@EastEriq Just for curiosity's sake, is there something about WebServices that you're specifically avoiding?

EastEriq commented 1 year ago

Sure, when hardware is in the loop, whether to report the command result or only the command acceptance, and come to check the result later, is among the design considerations and choices.

WebServices are provided by Labview only for windows, and I have not yet committed the project to a specific OS. Besides, as I haven't really looked into their bowels, is NI WS open code down to the last VI, as your implementation is? ;)

negentropicdev commented 1 year ago

The example is done and available in the repository. I'm going to be working on splitting the examples out into their own package so that the server version number doesn't keep getting bumped anytime I want to add another example. If you have trouble getting the repository version running you can wait a bit for me to get the packages changed over and view it from VIPM.

It runs a timer in a central loop and uses events to request state changes and status from the centralized loop to also demonstrate an example architecture for integrating into a "continuous" process.

EastEriq commented 1 year ago

got it, thanks.