简体   繁体   English

如何将剩余端点更改通知客户端

[英]How to notify the client about the Rest Endpoint changes

This question was asked to me recently in an interview: 最近在一次采访中问了这个问题:

You have one rest end point which is exposed to the client, Client uses this rest endpoint.Now, You have changed the rest endpoint, So if client hits the old rest end point url, How to notify the client that the rest end point has been changed? 您有一个向客户端公开的休息端点,客户端使用了该休息端点。现在,您已更改了休息端点,因此,如果客户端点击了旧的休息端点网址,如何通知客户端该休息端点已经被改变了吗?

you can inform client about Redirects that indicate the resource might be available at a different URI, as provided by the Location field, as in the status codes 301 (Moved Permanently), 302 (Found), and 307 (Temporary Redirect). 您可以通知客户端有关重定向的信息,该重定向指示资源可能在“位置”字段提供的其他URI上可用,如状态码301(永久移动),302(找到)和307(临时重定向)中所示。

like 喜欢

301 Moved Permanently: 301永久移动:

URI uri = ...
return Response.status(Status.MOVED_PERMANENTLY).location(uri).build();

307 Temporary Redirect: 307临时重定向:

URI uri = ...
return Response.temporaryRedirect(uri).build();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM