本文整理了Java中io.micronaut.http.HttpResponse.serverError()
方法的一些代码示例,展示了HttpResponse.serverError()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.serverError()
方法的具体详情如下:
包路径:io.micronaut.http.HttpResponse
类名称:HttpResponse
方法名:serverError
[英]Return an io.micronaut.http.HttpStatus#INTERNAL_SERVER_ERROR response with an empty body.
[中]返回一个io。微纳特。http。HttpStatus#内部_服务器_错误响应,正文为空。
代码示例来源:origin: micronaut-projects/micronaut-core
private MutableHttpResponse errorResultToResponse(Object result) {
MutableHttpResponse<?> response;
if (result == null) {
response = io.micronaut.http.HttpResponse.serverError();
} else if (result instanceof io.micronaut.http.HttpResponse) {
response = (MutableHttpResponse) result;
} else {
response = io.micronaut.http.HttpResponse.serverError()
.body(result);
MediaType.fromType(result.getClass()).ifPresent(response::contentType);
}
return response;
}
代码示例来源:origin: micronaut-projects/micronaut-core
@SuppressWarnings("unchecked")
private void writeDefaultErrorResponse(ChannelHandlerContext ctx, NettyHttpRequest nettyHttpRequest, Throwable cause) {
logException(cause);
MutableHttpResponse<?> error = io.micronaut.http.HttpResponse.serverError()
.body(new JsonError("Internal Server Error: " + cause.getMessage()));
subscribeToResponsePublisher(
ctx,
MediaType.APPLICATION_JSON_TYPE,
new AtomicReference<>(nettyHttpRequest),
Flowable.just(error)
);
}
代码示例来源:origin: micronaut-projects/micronaut-core
@Get(value = "/error-with-body", produces = MediaType.TEXT_PLAIN)
public HttpResponse errorWithBody() {
return HttpResponse.serverError().body("some text");
}
代码示例来源:origin: micronaut-projects/micronaut-core
return Flowable.just(HttpResponse.serverError());
}).map(response -> Collections.singletonMap(originalURI, response.getStatus()));
}).subscribe(uriToStatusMap -> {
代码示例来源:origin: micronaut-projects/micronaut-examples
@Post("/send")
public HttpResponse send(@Valid @Body Email email) {
log.info(email.toString());
if ( emailService == null ) {
log.warn("Email service not injected");
return HttpResponse.serverError();
}
emailService.send(email);
return HttpResponse.ok();
}
}
代码示例来源:origin: io.micronaut/http-client
return Flowable.just(HttpResponse.serverError());
}).map(response -> Collections.singletonMap(originalURI, response.getStatus()));
}).subscribe(uriToStatusMap -> {
代码示例来源:origin: io.micronaut/micronaut-http-client
return Flowable.just(HttpResponse.serverError());
}).map(response -> Collections.singletonMap(originalURI, response.getStatus()));
}).subscribe(uriToStatusMap -> {
内容来源于网络,如有侵权,请联系作者删除!