类的使用
org.redkale.net.http.HttpRequest
-
使用HttpRequest的程序包 程序包 说明 org.redkale.cluster.spi org.redkale.mq.spi org.redkale.net.http HTTP协议包,提供HTTP协议服务器 -
-
org.redkale.cluster.spi中HttpRequest的使用
org.redkale.cluster.spi中HttpRequest的子类 修饰符和类型 类 说明 static class
HttpLocalRpcClient.HttpMessageLocalRequest
参数类型为HttpRequest的org.redkale.cluster.spi中的构造器 构造器 说明 HttpMessageLocalResponse(HttpRequest req, CompletableFuture future)
-
org.redkale.mq.spi中HttpRequest的使用
org.redkale.mq.spi中HttpRequest的子类 修饰符和类型 类 说明 class
HttpMessageRequest
详情见: https://redkale.org -
org.redkale.net.http中HttpRequest的使用
返回HttpRequest的org.redkale.net.http中的方法 修饰符和类型 方法 说明 protected HttpRequest
HttpRequest. addHeader(String name, String value)
HttpRequest
HttpResponse. getRequest()
获取HttpRequestprotected HttpRequest
HttpRequest. initWebRequest(WebRequest req, boolean needPath)
protected HttpRequest
HttpRequest. removeHeader(String name)
protected HttpRequest
HttpRequest. removeParameter(String name)
<T extends Serializable>
HttpRequestHttpRequest. setCurrentUserid(T userid)
设置当前用户ID, 通常在HttpServlet.preExecute方法里设置currentUserid
数据类型只能是int、long、String、JavaBeanHttpRequest
HttpRequest. setCurrentUserSupplier(Supplier supplier)
建议使用 setCurrentUserid, 通过userid从Service或缓存中获取用户信息
设置当前用户信息, 通常在HttpServlet.preExecute方法里设置currentUser
数据类型由@HttpUserType指定protected HttpRequest
HttpRequest. setHeader(String name, String value)
protected HttpRequest
HttpRequest. setLocale(String locale)
protected HttpRequest
HttpRequest. setMethod(String method)
protected HttpRequest
HttpRequest. setParameter(String name, String value)
protected HttpRequest
HttpRequest. setRemoteAddr(String remoteAddr)
protected HttpRequest
HttpRequest. setRequestPath(String path)
返回变量类型为HttpRequest的类型的org.redkale.net.http中的方法 修饰符和类型 方法 说明 protected BiFunction<HttpRequest,RetResult,RetResult>
HttpResponse. getRetResultHandler()
获取输出RetResult时的拦截器参数类型为HttpRequest的org.redkale.net.http中的方法 修饰符和类型 方法 说明 protected void
HttpFilter. addHeader(HttpRequest request, String name, String value)
boolean
HttpRpcAuthenticator. auth(HttpRequest request, HttpResponse response)
成功返回true, 不成功返回false,且需要response.finish()输出失败的信息, 比如404boolean
HttpRpcSecretAuthenticator. auth(HttpRequest request, HttpResponse response)
protected void
HttpServlet. authenticate(HttpRequest request, HttpResponse response)
用户登录或权限验证, 注解为@HttpMapping.auth == true 的方法会执行authenticate方法, 若验证成功则必须调用response.nextEvent();进行下一步操作, 例如:
void
HttpDispatcherServlet. execute(HttpRequest request, HttpResponse response)
void
HttpResourceServlet. execute(HttpRequest request, HttpResponse response)
void
HttpServlet. execute(HttpRequest request, HttpResponse response)
void
WebSocketServlet. execute(HttpRequest request, HttpResponse response)
protected void
HttpServlet. finish404(HttpRequest request, HttpResponse response)
提供404状态码的可定制接口protected void
HttpServlet. finish405(HttpRequest request, HttpResponse response)
提供405状态码的可定制接口protected CompletableFuture<String>
WebSocket. onOpen(HttpRequest request)
返回sessionid, null表示连接不合法或异常,默认实现是request.sessionid(true),通常需要重写该方法protected void
HttpServlet. preExecute(HttpRequest request, HttpResponse response)
预执行方法,在execute方法之前运行,设置当前用户信息,或者加入常规统计和基础检测,例如 :
protected void
HttpFilter. removeHeader(HttpRequest request, String name)
protected void
HttpFilter. removeParameter(HttpRequest request, String name)
void
HttpRender. renderTo(HttpRequest request, HttpResponse response, Convert convert, HttpScope scope)
protected void
HttpFilter. setBody(HttpRequest request, byte[] body)
protected void
HttpFilter. setHeader(HttpRequest request, String name, String value)
protected void
HttpFilter. setLocale(HttpRequest request, String locale)
protected void
HttpFilter. setMethod(HttpRequest request, String method)
protected void
HttpFilter. setParameter(HttpRequest request, String name, String value)
protected void
HttpFilter. setPath(HttpRequest request, String path)
protected void
HttpFilter. setRemoteAddr(HttpRequest request, String remoteAddr)
static void
Rest. setRequestAnnotations(HttpRequest request, Annotation[] annotations)
类型变量类型为HttpRequest的org.redkale.net.http中的方法参数 修饰符和类型 方法 说明 void
HttpDispatcherServlet. addFilter(Filter<HttpContext,HttpRequest,HttpResponse> filter, AnyValue conf)
HttpServer
HttpServer. addHttpServlet(String mapping, BiConsumer<HttpRequest,HttpResponse> consumer)
添加HttpServletvoid
HttpResponse. retResultHandler(BiFunction<HttpRequest,RetResult,RetResult> retResultHandler)
设置输出RetResult时的拦截器参数类型为HttpRequest的org.redkale.net.http中的构造器 构造器 说明 HttpResponse(HttpContext context, HttpRequest request, HttpResponse.HttpResponseConfig config)
-