在基于RESTful的应用程序中管理状态 [英] Managing state in RESTful based application

查看:77
本文介绍了在基于RESTful的应用程序中管理状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在评估用于基于Web的应用程序的技术,并且一些建议与基于RESTful的服务方法一起使用. 技术堆栈

We are evaluating the technology to be used for a web based application and some suggestions are to go with RESTful based services approach. Tech Stack

1)春天 2)Apache CXF(JAX-RS)

1) Spring 2) Apache CXF ( JAX-RS)

我的问题是

1)如何在请求之间管理状态.例如,一个用户已经过身份验证,现在他正在发出一系列请求,比如说要查看分页的报告.我可以想象它的URL就像

1) How state is managed between requests. For example, a user has been authenticated and now he is making a series of requests lets say going through a paginated report. I would imagine the URL for this will be like

domain.com/reports/customreport/page/1 domain.com/reports/customreport/page/2 等等...

domain.com/reports/customreport/page/1 domain.com/reports/customreport/page/2 etc...

a)用户信息在哪里?存储请求参数,以便可以在请求之间共享. b)可以说结果正在流式传输,行集存储在哪里?

a) Where is the user information & request parameters are stored so that it can be shared between requests. b) Lets say the result is being streamed, where is Rowset is stored?

是否有一个与Petclinic类似的完整示例应用程序,可以为此类应用程序提供最佳实践.

Is there a complete sample application something similar to Petclinic that can provide the best practices for such an application.

推荐答案

如果严格/正确地执行RESTful,则将在每个请求中完成用户身份验证,并且没有会话的概念.每个请求都包含足够的上下文信息(在URL和/或请求参数中),以使其能够独立于会话运行.

If you are doing RESTful strictly / properly, then user authentication is done in each request and there is no concept of a session. Each request contains enough context information (in the URL and/or request parameters) to allow it to work independent of a session.

1)如何在请求之间管理状态.

1) How state is managed between requests.

它必须由客户端管理.

a)用户信息在哪里?存储请求参数,以便可以在请求之间共享.

a) Where is the user information & request parameters are stored so that it can be shared between requests.

用户身份验证信息由客户端存储,并随每个请求提供给服务器.服务器将在每个请求上重新计算有关用户的任何派生信息.通常会存储在服务器端会话"中的所有请求参数都必须随每个请求一起重新传递.

User authentication information is stored by the client and provided to the server with each request. The server will recalculate any derived information about the user on each request. Any request parameters that would normally be stored in a server-side "session" must be passed afresh with each request.

b)可以说结果正在流式传输,行集存储在哪里?

b) Lets say the result is being streamed, where is Rowset is stored?

在第一瞬间,无处.每次重新发出查询时都会带有一个参数,该参数说明要跳转到的位置.如果性能是一个问题,您可以

In the first instant, nowhere. The query is reissued each time with a parameter saying where to skip to. If performance was an issue, you could

  • 预先读取结果集的几页并将其存储在服务器端缓存中,或者
  • 调整查询的数据库查询缓存.

这篇关于在基于RESTful的应用程序中管理状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆