Java Code Examples for com.linecorp.armeria.common.HttpResponse#ofFailure()

The following examples show how to use com.linecorp.armeria.common.HttpResponse#ofFailure() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EurekaWebClient.java    From armeria with Apache License 2.0 5 votes vote down vote up
/**
 * Registers the specified {@link InstanceInfo} to the Eureka registry.
 */
public HttpResponse register(InstanceInfo info) {
    requireNonNull(info, "info");
    final String path = APPS + info.getAppName();
    final RequestHeaders headers = RequestHeaders.builder(HttpMethod.POST, path)
                                                 .contentType(MediaType.JSON)
                                                 .build();
    try {
        return webClient.execute(headers, mapper.writeValueAsBytes(info));
    } catch (JsonProcessingException e) {
        return HttpResponse.ofFailure(e);
    }
}
 
Example 2
Source File: DefaultWebClient.java    From armeria with Apache License 2.0 4 votes vote down vote up
DefaultWebClient(ClientBuilderParams params, HttpClient delegate, MeterRegistry meterRegistry) {
    super(params, delegate, meterRegistry,
          HttpResponse::from, (ctx, cause) -> HttpResponse.ofFailure(cause));
}
 
Example 3
Source File: DefaultWebClient.java    From armeria with Apache License 2.0 4 votes vote down vote up
private static HttpResponse abortRequestAndReturnFailureResponse(
        HttpRequest req, IllegalArgumentException cause) {
    req.abort(cause);
    return HttpResponse.ofFailure(cause);
}