本文整理汇总了Java中io.vertx.core.http.HttpServerResponse.getStatusCode方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServerResponse.getStatusCode方法的具体用法?Java HttpServerResponse.getStatusCode怎么用?Java HttpServerResponse.getStatusCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.http.HttpServerResponse
的用法示例。
在下文中一共展示了HttpServerResponse.getStatusCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: responseEnd
import io.vertx.core.http.HttpServerResponse; //导入方法依赖的package包/类
@Override
public void responseEnd(StopWatch requestWatch, HttpServerResponse response) {
requestWatch.stop();
counterService.increment("responses.count.total");
int statusCode = response.getStatusCode();
long totalTimeMillis = requestWatch.getTotalTimeMillis();
gaugeService.submit("responses.totalTime.all", totalTimeMillis);
if (statusCode > 400) {
gaugeService.submit("responses.totalTime.error.all", totalTimeMillis);
counterService.increment("responses.count.error.total");
if (statusCode > 500) {
counterService.increment("responses.count.error.server");
gaugeService.submit("responses.totalTime.error.server", totalTimeMillis);
} else {
counterService.increment("responses.count.error.client");
gaugeService.submit("responses.totalTime.error.client", totalTimeMillis);
}
} else if (statusCode > 300) {
counterService.increment("responses.count.redirect");
gaugeService.submit("responses.totalTime.redirect", totalTimeMillis);
} else if (statusCode > 200) {
counterService.increment("responses.count.success");
gaugeService.submit("responses.totalTime.success", totalTimeMillis);
}
}
示例2: write
import io.vertx.core.http.HttpServerResponse; //导入方法依赖的package包/类
@Override
public void write(Throwable exception, HttpServerRequest request, HttpServerResponse response) {
response.setStatusCode(406);
ErrorJSON error = new ErrorJSON();
error.code = response.getStatusCode();
error.message = exception.getMessage();
response.end(JsonUtils.toJson(error));
}