开发者

REST doesn't work with Sever-Client-Client setup

开发者 https://www.devze.com 2022-12-29 14:56 出处:网络
I am having a problem with my current RESTful api design. What I have is a REST api which is consumed by Django web-server, which renders the HTML templates.

I am having a problem with my current RESTful api design.

What I have is a REST api which is consumed by Django web-server, which renders the HTML templates.

    REST api 
        > Django webserver
                 > HTML
开发者_Python百科

The problem I am encountering is that I have to reconstruct all the URLS like

mysite.com/main/cities/<id>/streets/

into equivalent rest api urls on my web-server layer:

api.com/cities/<id>/streets/

Thus I have a lot of mapping back and forth, but as far as I know REST says that the client (in this case my web-server) should NOT need to know how to re-construct the urls.

Can REST be used for such a setup and how? Or is it only viable for Server-Client architecture.

Thanks


I think what you are trying to do is really quite tricky. Assuming your web server is using HTTP properly (e.g. no session state) you are actually trying to layer one REST service on top of another REST service. This means that you have "application state" at the web server level that you need to transfer down to the client and manage along side the actual client state. My head hurts thinking about it.

I have not seen this type of REST service composition done much. However, Ceasare Pautasso has a research paper on it here. In his case he is going a step further and using two REST services to create a third composite service.


Why don't you let the web server rewrite the URLs?

0

精彩评论

暂无评论...
验证码 换一张
取 消