This commit is contained in:
Redkale
2017-05-13 10:50:52 +08:00
parent 0be3d8a4fa
commit a5756c0b4d
8 changed files with 73 additions and 58 deletions

View File

@@ -68,6 +68,8 @@ public class HttpRequest extends Request<HttpContext> {
protected int actionid;
protected Object currentUser;
private final String remoteAddrHeader;
Object attachment; //供 HttpBaseServlet传递Entry使用
@@ -240,6 +242,33 @@ public class HttpRequest extends Request<HttpContext> {
return super.removeProperty(name);
}
/**
* 设置当前用户信息, 通常在HttpServlet.authenticate方法里设置currentUser <br>
* 数据类型由&#64;HttpUserType指定
*
* @param <T> 泛型
* @param user 用户信息
*
* @return HttpRequest
*/
public <T> HttpRequest currentUser(T user) {
this.currentUser = user;
return this;
}
/**
* 获取当前用户信息, 通常在HttpServlet.authenticate方法里设置currentUser <br>
* 数据类型由&#64;HttpUserType指定
*
* @param <T> &#64;HttpUserType指定的用户信息类型
*
* @return 用户信息
*/
@SuppressWarnings("unchecked")
public <T> T currentUser() {
return (T) this.currentUser;
}
/**
* 获取模块ID来自&#64;HttpServlet.moduleid()
*
@@ -403,6 +432,7 @@ public class HttpRequest extends Request<HttpContext> {
this.bodyparsed = false;
this.moduleid = 0;
this.actionid = 0;
this.currentUser = null;
this.attachment = null;