Hello Taher,

Taher Alkhateeb <slidingfilame...@gmail.com> writes:

> Before we dig into the details, may I first understand _why_ are you
> adding that functionality in the first place? In other words, you can
> decide on the HTTP protocol from the calling page right? If it is a
> form, it's a POST, if it is a URL, it's a GET, or you can override
> that in certain areas using the OFBiz DSL. So what is the purpose here
> of adding this functionality in the controller? If we implement a
> RESTFUL API, wouldn't we still decide on the HTTP protocol from the
> client side? Or am I missing something here?

I guess by “HTTP protocol” you actually meant “HTTP method”.  The reason
I want to add a ‘method’ attribute is that I want the controller to be
able to provide a RESTful API, where each HTTP method has semantics
attached to it [1].

The controller is where requests are dispatched to there corresponding
handler (event, service, view).  Currently it is written in a RPC way
where URI refers to *actions* instead of *resources*. For example take
the Geo management from the webtools controller:

    <request-map uri="LookupGeo">...</request-map>
    <request-map uri="createGeo">...</request-map>
    <request-map uri="updateGeo">...</request-map>
    <request-map uri="deleteGeo">...</request-map>

In order to implement a RESTful API with the same capability.  The idea
is to define a “geos” resouce which is a container of geo resources and
implement the different *actions* available on those resources via the
various HTTP methods available.  So this would convert into something
like this:

    <request-map uri="geos" method="get">...</request-map>
    <request-map uri="geos" method="post">...</request-map>
    <request-map uri="geos/{id}" method="update">...</request-map>
    <request-map uri="geos/{id}" method="delete">...</request-map>

The last two examples requires additional changes that are not
implemented in the patches from OFBIZ-10458:

    - Handling URI templates
    - Replacing the overridden view URI feature with an alternate solution.

I am currently working on this in parallel of the JSON view handler.

Does this additional explanation and example help?

Thanks for the feedback.

[1] https://www.restapitutorial.com/lessons/httpmethods.html

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37

Reply via email to