Modifying URLs on a Rest Server in Delphi

后端 未结 3 566
清歌不尽
清歌不尽 2021-01-13 06:27

I\'ve written a REST server in Delphi XE (using the wizard) and I want to change the URLs a bit so that instead of having http://192.168.1.84:8080/datasnap/rest/TServerMetho

相关标签:
3条回答
  • 2021-01-13 06:38

    URL rewriting is usually done in the web server configuration, in Apache using entries in the .htaccess file

    0 讨论(0)
  • 2021-01-13 06:51

    You could put IIS or Apache in between to accomplish this, and indeed rewrite the URL to point to your service the way you like.

    That provides some more advantages anyway (security and scalability mostly). For example, you can create a fail-safe setup with double servers, or you can create multiple machines with your service, and have your web server do the load balancing for example.

    You'll get extra logging capabilities, and if you easily want to serve other web content it's easy to have a full fledged web server anyway.

    0 讨论(0)
  • 2021-01-13 06:53

    The naming convention is (Delphi XE3):

    http://my.site.com/datasnap/rest/URIClassName/URIMethodName[/inputParameter]

    You can easily change the "datasnap" and "rest" part of the URL in the TDSHTTPWebDispatcher component properties. You can change the Class Name and Method Name of the URL by simply changing the name of your class and method. However, you still have to have 4 components to the URL, so for example it could be:

    http://my.site.com/api/v1/People/Listing

    See here:

    http://docwiki.embarcadero.com/RADStudio/XE3/en/REST#Customizing_the_URL_for_REST_requests

    0 讨论(0)
提交回复
热议问题