public class Context extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected cn.xnatural.xchain.Lazier<Map<String,Object>> |
_queryParams
路径查询参数 ?
|
protected cn.xnatural.xchain.Lazier<String> |
_queryStr
查询字符串
|
protected Object[] |
attach
额外附加对象
|
protected Map<String,Object> |
attrs
当前执行上下文属性集
|
Date |
createTime
消息处理的开始时间
|
protected Function<Context,String> |
idProvider
处理id: 唯一
|
BiFunction<String,Class,Object> |
paramProvider
消息的参数供应函数
|
String |
path
路由路径
|
protected Map<String,String> |
pathToken
路径变量值映射
|
protected IMvc |
server |
| 限定符 | 构造器和说明 |
|---|---|
protected |
Context(String path,
Function<Context,String> idProvider,
BiFunction<String,Class,Object> paramProvider,
IMvc server)
请求执行上下文
|
| 限定符和类型 | 方法和说明 |
|---|---|
Set<String> |
accept()
响应内容类型
Route.produce()}} |
Object[] |
attach()
附加对象
|
protected Context |
attach(Object... attach)
添加附加对象
|
String |
contentType()
请求内容类型
Route.consume()} |
<T> T |
getAttr(String aName)
获取请求属性
|
<T> T |
getAttr(String aName,
Class<T> aType)
获取请求属性
|
String |
getQueryStr()
请求url 的查询字符串 ?
|
String |
id()
处理id 唯一
|
String |
method()
协议
Route.method()} |
<T> T |
param(Class<T> type)
根据参数类型查找
param(String, Class) |
Object |
param(String pName)
根据参数名查找
param(String, Class) |
<T> T |
param(String pName,
Class<T> type)
取请求参数值
|
String |
protocol()
|
Map<String,Object> |
queryParams()
路径后边的查询参数
|
Object |
render(Object body)
同步响应
|
void |
render(Object body,
Consumer afterFn)
异步响应
|
Context |
setAttr(String key,
Object value)
设置请求属性
|
<T> Context |
setAttr(String key,
Supplier<T> supplier)
设置请求 懒计算 属性
|
protected final IMvc server
protected final cn.xnatural.xchain.Lazier<String> _queryStr
protected final cn.xnatural.xchain.Lazier<Map<String,Object>> _queryParams
public final BiFunction<String,Class,Object> paramProvider
public final String path
public final Date createTime
protected Object[] attach
public Object[] attach()
public String id()
public String protocol()
public String getQueryStr()
public String method()
Route.method()}public String contentType()
Route.consume()}public Set<String> accept()
Route.produce()}}public Context setAttr(String key, Object value)
key - 属性keyvalue - 属性值Contextpublic <T> Context setAttr(String key, Supplier<T> supplier)
key - 属性keysupplier - 属性值计算器Contextpublic <T> T getAttr(String aName)
aName - 属性名public <T> T getAttr(String aName, Class<T> aType)
aName - 属性名aType - 属性类型public Object param(String pName)
param(String, Class)pName - 参数名public <T> T param(Class<T> type)
param(String, Class)type - 类型Copyright © 2023. All rights reserved.