在 Delphi 中修改 Rest 服务器上的 URL

发布于 2024-10-05 16:16:29 字数 367 浏览 0 评论 0原文

我已经在 Delphi XE 中编写了一个 REST 服务器(使用向导),并且我想稍微更改一下 URL,这样就不用 http://192.168.1.84:8080/datasnap/rest/TServerMethods1/GetListings 我得到的东西看起来更像 http://192.168.1.84:8080/GetListings

有没有一个很好的简单方法这样做?

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/TServerMethods1/GetListings
I get something that looks more like http://192.168.1.84:8080/GetListings

Is there a nice easy of doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

温柔一刀 2024-10-12 16:16:29

命名约定是(Delphi XE3):

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

您可以轻松更改 TDSHTTPWebDispatcher 组件中 URL 的“datasnap”和“rest”部分特性。您只需更改类和方法的名称即可更改 URL 的类名称和方法名称。但是,您仍然必须有 4 个 URL 组件,例如它可以是:

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

请参阅此处:

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

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

别低头,皇冠会掉 2024-10-12 16:16:29

您可以将 IIS 或 Apache 置于中间来完成此操作,并且实际上可以按照您喜欢的方式重写 URL 以指向您的服务。

无论如何,这提供了更多优势(主要是安全性和可扩展性)。例如,您可以使用双服务器创建故障安全设置,或者可以使用您的服务创建多台计算机,并让您的 Web 服务器执行负载平衡等操作。

您将获得额外的日志记录功能,并且如果您想轻松地提供其他 Web 内容,那么无论如何都可以轻松拥有一个成熟的 Web 服务器。

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.

冷弦 2024-10-12 16:16:29

URL 重写通常在 Web 服务器配置中完成,在 Apache 中使用 .htaccess 文件中的条目

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文