本文整理汇总了Java中io.vertx.core.http.HttpServerResponse.setStatusMessage方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServerResponse.setStatusMessage方法的具体用法?Java HttpServerResponse.setStatusMessage怎么用?Java HttpServerResponse.setStatusMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.http.HttpServerResponse
的用法示例。
在下文中一共展示了HttpServerResponse.setStatusMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reply
import io.vertx.core.http.HttpServerResponse; //导入方法依赖的package包/类
public static void reply(
final RoutingContext context,
final Envelop envelop) {
// 1. Get response reference
final HttpServerResponse response
= context.response();
// 2. Set response status
final HttpStatusCode code = envelop.status();
response.setStatusCode(code.code());
response.setStatusMessage(code.message());
response.putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
// 3. Response process
if (!response.ended()) {
response.end(envelop.response());
}
response.close();
}
示例2: handle
import io.vertx.core.http.HttpServerResponse; //导入方法依赖的package包/类
public void handle(RoutingContext ctx)
{
HttpServerResponse response = ctx.response();
if(userManager.isLogined(ctx)){
try {
String uid = userManager.getUid(userManager.getIdFromSession(ctx));
String result = requestManager.createApiKey(uid);
if(result != null){
response.setStatusCode(200);
response.setStatusMessage(result);
}
} catch (SQLException e) {
e.printStackTrace();
response.setStatusCode(500);
}
}else{
response.setStatusCode(400);
}
response.end();
response.close();
}
示例3: onFailure
import io.vertx.core.http.HttpServerResponse; //导入方法依赖的package包/类
protected void onFailure(RoutingContext context) {
LOGGER.error("edge server failed.", context.failure());
HttpServerResponse response = context.response();
response.setStatusCode(Status.BAD_GATEWAY.getStatusCode());
response.setStatusMessage(Status.BAD_GATEWAY.getReasonPhrase());
response.end();
}