- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.jetdrone.vertx.yoke.middleware.YokeResponse
类的一些代码示例,展示了YokeResponse
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YokeResponse
类的具体详情如下:
包路径:com.jetdrone.vertx.yoke.middleware.YokeResponse
类名称:YokeResponse
[英]# YokeResponse
[中]#负责任
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
request.response().putHeader("Allow", "GET").setStatusCode(405).end();
}
});
代码示例来源:origin: pmlopes/yoke
public void redirect(String url) {
redirect(302, url);
}
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
if ("/favicon.ico".equals(request.normalizedPath())) {
request.response().headers().setAll(icon.headers);
request.response().end(icon.body);
} else {
next.handle(null);
}
}
}
代码示例来源:origin: pmlopes/yoke
public void redirect(int status, String url) {
setStatusCode(status);
setStatusMessage(HttpResponseStatus.valueOf(status).reasonPhrase());
putHeader("location", url);
end();
}
代码示例来源:origin: pmlopes/yoke
public void jsonp(String callback, String body) {
if (callback == null) {
// treat as normal json response
setContentType("application/json", "UTF-8");
end(body);
return;
}
if (body == null) {
body = "null";
}
// replace special chars
body = body.replaceAll("\\u2028", "\\\\u2028").replaceAll("\\u2029", "\\\\u2029");
// content-type
setContentType("text/javascript", "UTF-8");
String cb = callback.replaceAll("[^\\[\\]\\w$.]", "");
end(cb + " && " + cb + "(" + body + ");");
}
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
request.response().setStatusCode(400).end("Can \"Upgrade\" only to \"WebSocket\".");
}
});
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(JsonObject user) {
if (user != null) {
JsonObject session = request.createSession();
session.put("user", request.getFormAttribute("username"));
// get the redirect_url parameter
String redirect = request.getParam("redirect_url", "/");
request.response().redirect(Utils.decodeURIComponent(redirect));
} else {
if (loginTemplate != null) {
// render internal login
request.response().setContentType("text/html");
request.response().setStatusCode(401);
request.response().end(
loginTemplate.replace("{title}", (String) request.get("title"))
.replace("{action}", loginURI + "?redirect_url=" + Utils.encodeURIComponent(request.getParam("redirect_url", "/")))
.replace("{message}", "Invalid username and/or password, please try again."));
} else {
next.handle(401);
}
}
}
});
代码示例来源:origin: pmlopes/yoke
public void close() {
if (!closed) {
try {
session.resetListener();
rc.response().end();
rc.response().close();
closed = true;
} catch (IllegalStateException e) {
// Underlying connection might already be closed - that's fine
}
}
}
}
代码示例来源:origin: pmlopes/yoke
@Override
public void writeResponseContent(String content) {
response.end(content);
}
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
if (dt - 500 * 1000000 > highWaterMark) {
final YokeResponse response = request.response();
response.setStatusCode(503);
response.setStatusMessage(message);
response.end();
} else {
next.handle(null);
}
}
}
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
if ("/crossdomain.xml".equals(request.path())) {
request.response().putHeader("Content-Type", "text/x-cross-domain-policy");
request.response().end(DATA);
} else {
next.handle(null);
}
}
}
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(Object error) {
if (error != null) {
int errorCode;
// if the error was set on the response use it
if (getStatusCode() >= 400) {
errorCode = getStatusCode();
} else {
// if it was set as the error object use it
if (error instanceof Number) {
errorCode = ((Number) error).intValue();
} else if (error instanceof YokeException) {
errorCode = ((YokeException) error).getErrorCode().intValue();
} else {
// default error code
errorCode = 500;
}
}
setStatusCode(errorCode);
setStatusMessage(HttpResponseStatus.valueOf(errorCode).reasonPhrase());
end(HttpResponseStatus.valueOf(errorCode).reasonPhrase());
}
}
});
代码示例来源:origin: pmlopes/yoke
if (loginTemplate != null) {
request.response().setContentType("text/html");
request.response().end(
loginTemplate.replace("{title}", (String) request.get("title"))
.replace("{action}", loginURI + "?redirect_url=" + Utils.encodeURIComponent(request.getParam("redirect_url", "/")))
} else {
request.response().render(userLoginTemplate, next);
request.response().redirect(Utils.decodeURIComponent(redirect));
return;
代码示例来源:origin: pmlopes/yoke
/**
* Write a file into the response body
*
* @param request
* @param file
* @param props
*/
private void sendFile(final YokeRequest request, final String file, final FileProps props) {
// write content type
String contentType = MimeType.getMime(file);
String charset = MimeType.getCharset(contentType);
request.response().setContentType(contentType, charset);
request.response().putHeader("Content-Length", Long.toString(props.size()));
// head support
if (HttpMethod.HEAD.equals(request.method())) {
request.response().end();
} else {
request.response().sendFile(file);
}
}
代码示例来源:origin: pmlopes/yoke
public void jsonp(String callback, JsonArray json) {
if (callback == null) {
// treat as normal json response
end(json);
return;
}
String body = null;
if (json != null) {
body = json.encode();
}
jsonp(callback, body);
}
代码示例来源:origin: pmlopes/yoke
if (response.getStatusCode() < 400) {
response.setStatusCode(getErrorCode(request.get("error")));
request.put("error", response.getStatusCode());
int errorCode = response.getStatusCode();
response.setStatusMessage(HttpResponseStatus.valueOf(errorCode).reasonPhrase());
String mime = response.getHeader("content-type");
代码示例来源:origin: pmlopes/yoke
public YokeResponse setContentType(String contentType, String contentEncoding) {
if (contentEncoding == null) {
putHeader("content-type", contentType);
} else {
putHeader("content-type", contentType + ";charset=" + contentEncoding);
}
return this;
}
代码示例来源:origin: pmlopes/yoke
public void sendFrame(String body) {
if (log.isTraceEnabled()) log.trace("JsonP, sending frame");
if (!headersWritten) {
rc.response().setChunked(true).putHeader("Content-Type", "application/javascript; charset=UTF-8");
setNoCacheHeaders(rc);
setJSESSIONID(options, rc);
headersWritten = true;
}
body = escapeForJavaScript(body);
StringBuilder sb = new StringBuilder();
sb.append(callback).append("(\"");
sb.append(body);
sb.append("\");\r\n");
//End the response and close the HTTP connection
rc.response().write(sb.toString());
close();
}
代码示例来源:origin: pmlopes/yoke
public void handle(HttpClientResponse cRes) {
req.response().setStatusCode(cRes.statusCode());
req.response().headers().setAll(cRes.headers());
req.response().setChunked(true);
cRes.handler(new Handler<Buffer>() {
public void handle(Buffer data) {
req.response().write(data);
}
});
cRes.endHandler(new VoidHandler() {
public void handle() {
req.response().end();
}
});
cRes.exceptionHandler(new Handler<Throwable>() {
public void handle(Throwable t) {
next.handle(t);
}
});
}
});
代码示例来源:origin: pmlopes/yoke
/**
* Handle all forbidden errors, in this case we need to add a special header to the response
*
* @param request yoke request
* @param next middleware to be called next
*/
private void handle401(final YokeRequest request, final Handler<Object> next) {
YokeResponse response = request.response();
response.putHeader("WWW-Authenticate", "Basic realm=\"" + getRealm(request) + "\"");
response.setStatusCode(401);
next.handle("No authorization token");
}
本文整理了Java中com.jetdrone.vertx.yoke.middleware.YokeResponse.putHeader()方法的一些代码示例,展示了YokeResponse.putHe
本文整理了Java中com.jetdrone.vertx.yoke.middleware.YokeResponse.redirect()方法的一些代码示例,展示了YokeResponse.redire
本文整理了Java中com.jetdrone.vertx.yoke.middleware.YokeResponse.end()方法的一些代码示例,展示了YokeResponse.end()的具体用法。
本文整理了Java中com.jetdrone.vertx.yoke.middleware.YokeResponse.setContentType()方法的一些代码示例,展示了YokeResponse.
本文整理了Java中com.jetdrone.vertx.yoke.middleware.YokeResponse.headers()方法的一些代码示例,展示了YokeResponse.headers
本文整理了Java中com.jetdrone.vertx.yoke.middleware.YokeResponse.setStatusCode()方法的一些代码示例,展示了YokeResponse.s
本文整理了Java中com.jetdrone.vertx.yoke.middleware.YokeResponse.setStatusMessage()方法的一些代码示例,展示了YokeRespons
我是一名优秀的程序员,十分优秀!