Configuration page design

by user138741   Last Updated January 24, 2018 00:05 AM

I've been struggling how to go about a particular design portion of my project at work. I asked a question on here recently but I'm not convinced I'm taking the right path.

In my last post, I was asking how to interface between my server program and a web api. However, in reflection, I'm not sure if this is the best approach. The design of it all seems really hairy and I am taking a step backwards in hope of finding some answers.

One of the aspects of my project over all is that I will have an embedded device doing some tasks that will ultimately require a report to be printed. This device sends data up to my device server which will be stored in a database and then later sends a request to print parts of the aforementioned data. That part is largely solved. We have the need for a user interface with this project, and we want to make it as portable as possible (we have goals of being able to access configurations of our devices through a mobile device in later stages).

So, for sake of example here, let's say I have a few functionalities I need to achieve. 1) List all available printers to the computer running the server software, 2) Select a printer to use, 3) Display which printer is selected for printing. 4) Later on (not now), be able to select portions of data manually to print. This is an interaction between the device server and the web interface (what I envision is a similar router configuration page where you can go in and modify router settings).

I'm curious if there is any form of a best practice for what I'm trying to achieve. The reason I thought REST API initially is because it provides a nice interface to access and modify server settings (GET/POST), but when it came to mocking things up for prototyping, I have no idea if I was doing it correctly. With a REST API, you'd make an api call out to something like 127.0.0.1:80/api/print. Where I get confused is the differentiation for my different calls that I need to make. For instance, how would I differentiate between wanting to display the current selected printer, versus getting a list of available printers? I don't see an obvious solution (being a complete novice to this technology). I see these two functionalities being GET requests as they're getting something from the server, but when it comes to specifics of how to call the individual methods, I get lost, and that's why I think I'm going down the wrong road with this.

I suppose one way I could design this is just by using a id value on get. Something like 127.0.0.1:80/api/print/0 would return a list of printers, and 127.0.0.1:80/api/print/1 would return the current selected. In general though, I don't like the way this feels. It gives me what I need, but it feels like a kludge. Is there a more elegant way of doing this, or should I be creating lots of controllers with only a few functionalities (api/GetPrinters, api/GetCurrentPrinter, api/SetCurrentPrinter, api/PrintReport?{params})?

Thanks for you time, sorry for the poorly written question. I'm in a phase with my learning of this where I know what I'm trying to do but don't know how to ask the questions elegantly.

Tags : rest api


Related Questions



Google CustomSearch API Image Search Not Working

Updated May 30, 2015 04:02 AM


RESTful way of requesting server generated resource

Updated March 31, 2016 08:02 AM