[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tentative Schedule for 1.4



On 02/24/2012 05:44 PM, Chris Travers wrote:


Ideally web services, like reporting, would happen after the main transactional functionality is stable enough for early beta testing.

I think the first step is getting a framework in place that defines the endpoints, the formatting of the data, etc. Something that converts a web service payload into some sort of Perl object that can be populated based on LSMB data.

So maybe a script which:
1)  Converts XML and JSON into a $request object
2)  Converts a $request object to XML or JSON
3)  Hands off to web service modules for URL parsing and work

I am thinking those web service modules would all accept three arguments: $request, $url, $method

When I've done this before I've set it up slightly differently:

1. Deserialize request into some standard data structure ($request object) with headers, hash of data passed/deserialized request body, path
2. Main controller parses URL and uses conventions to load controller for a specific request, creates an appropriate response object based on request
3. Main controller calls standard method (determined by HTTP method/specific parameters) on the controller object with $request and $response object
4. Specific controllers load up native DB objects, populate with incoming data, call methods appropriate to actions, and populates $response object
5. Main controller returns serialized $response object

I'd say the main difference is taking the standard centralized stuff one step further than you've outlined, doing the URL parsing and establishing conventions before handing off to individual web service controllers.

I've also found it useful to have separate request and response objects, though at the moment I don't recall why. And of course have a different class for each type of response and request -- XML, JSON, HTML, etc. -- that implement standard methods that the framework can call regardless of type.


I am also thinking the stuff we are doing with Moose will make this better in the long-run.  We can use the defined data structures there as both the documented API and the basis for XML and JSON formats.

Excellent. Is this going to be available in 1.4?

Cheers,
John Locke
http://www.freelock.com