Browse Source
* Add support for multiple ResponseInterceptors * Address PR comments --------- Co-authored-by: Marvin Froeder <marvin.froeder@police.govt.nz> Co-authored-by: Marvin Froeder <velobr@gmail.com>pull/1999/merge
Marvin Froeder
1 year ago
committed by
GitHub
10 changed files with 137 additions and 90 deletions
@ -1,58 +0,0 @@
@@ -1,58 +0,0 @@
|
||||
/* |
||||
* Copyright 2012-2023 The Feign Authors |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
||||
* in compliance with the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License |
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
||||
* or implied. See the License for the specific language governing permissions and limitations under |
||||
* the License. |
||||
*/ |
||||
package feign; |
||||
|
||||
import static feign.FeignException.errorReading; |
||||
import feign.codec.DecodeException; |
||||
import feign.codec.Decoder; |
||||
import java.io.IOException; |
||||
import java.lang.reflect.Type; |
||||
|
||||
public class InvocationContext { |
||||
|
||||
private final Decoder decoder; |
||||
private final Type returnType; |
||||
private final Response response; |
||||
|
||||
InvocationContext(Decoder decoder, Type returnType, Response response) { |
||||
this.decoder = decoder; |
||||
this.returnType = returnType; |
||||
this.response = response; |
||||
} |
||||
|
||||
public Object proceed() { |
||||
try { |
||||
return decoder.decode(response, returnType); |
||||
} catch (final FeignException e) { |
||||
throw e; |
||||
} catch (final RuntimeException e) { |
||||
throw new DecodeException(response.status(), e.getMessage(), response.request(), e); |
||||
} catch (IOException e) { |
||||
throw errorReading(response.request(), response, e); |
||||
} |
||||
} |
||||
|
||||
public Decoder decoder() { |
||||
return decoder; |
||||
} |
||||
|
||||
public Type returnType() { |
||||
return returnType; |
||||
} |
||||
|
||||
public Response response() { |
||||
return response; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue