On Wed, Feb 6, 2013 at 4:04 PM, Gabriel Wicke <[email protected]> wrote:
> On 02/06/2013 11:43 AM, Brad Jorsch wrote:
>> On Wed, Feb 6, 2013 at 11:54 AM, Gabriel Wicke <[email protected]> wrote:
>>>
>>> It should be possible to hide optimization details like local DB access
>>> vs. an actual HTTP request behind the same interface. A URL-based query
>>> interface can support local handlers for specific URL prefixes.
>>
>> Or the interface can just look like a function call. Which seems a
>> whole lot more straightforward than forcing people to encode a URL in
>> Lua which is then passed to PHP and decoded to determine if it should
>> be sent out as a remote request or looked up in the local DB.
> I don't know much Lua, but a function call like this does not seem to be
> *that* hard to use:
>
> -- Would fetch JSON from
> -- http://wikidata.org/api/query/?param1=foo&param2=bar
> -- if no local handler is defined and the base URL is in a whitelist
> jsonObject = JSONRequest("http://wikidata.org/api/query/";,
>                          { param1="foo", param2="bar" } )
>
> No manual encoding, and URL encoding can be completely skipped if the
> prefix happens to match a registered local handler. An optional third
> parameter can pass in a table to specify the request method and other
> options.

Having a method with a very generic and suggestive name like
"JSONRequest" that only works for one long magic value of the first
parameter seems like a bad design to me.

Also note it's not actually taking JSON as input, it's taking a Lua table.


-- 
Brad Jorsch
Software Engineer
Wikimedia Foundation

_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to