{"action":"created","issue":{"url":"https://api.github.com/repos/OpenFeign/feign/issues/294","repository_url":"https://api.github.com/repos/OpenFeign/feign","labels_url":"https://api.github.com/repos/OpenFeign/feign/issues/294/labels{/name}","comments_url":"https://api.github.com/repos/OpenFeign/feign/issues/294/comments","events_url":"https://api.github.com/repos/OpenFeign/feign/issues/294/events","html_url":"https://github.com/OpenFeign/feign/issues/294","id":114932605,"number":294,"title":"OptionalAwareDecoder in feign core?","user":{"login":"uschi2000","id":6528449,"avatar_url":"https://avatars.githubusercontent.com/u/6528449?v=3","gravatar_id":"","url":"https://api.github.com/users/uschi2000","html_url":"https://github.com/uschi2000","followers_url":"https://api.github.com/users/uschi2000/followers","following_url":"https://api.github.com/users/uschi2000/following{/other_user}","gists_url":"https://api.github.com/users/uschi2000/gists{/gist_id}","starred_url":"https://api.github.com/users/uschi2000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uschi2000/subscriptions","organizations_url":"https://api.github.com/users/uschi2000/orgs","repos_url":"https://api.github.com/users/uschi2000/repos","events_url":"https://api.github.com/users/uschi2000/events{/privacy}","received_events_url":"https://api.github.com/users/uschi2000/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2015-11-03T23:17:25Z","updated_at":"2016-12-22T12:45:46Z","closed_at":null,"body":"Hej again,\nHow are the chances of getting a \"feign-guava-optional\" module (or similar) into feign that knows about 404-decoding Guava Optional? Such a module would have a Guava dependency and only make sense where decode404 is enabled.\n  R.\n\n```\n/**\n * Decorates a Feign {@link Decoder} such that it returns {@link Optional#absent} when observing an HTTP 404 error code\n * for a method with {@link Type} {@link Optional}. Propagates the exception returned by the given {@link ErrorDecoder}\n * in case the response is 404 for a non-Optional method.\n */\npublic final class OptionalAwareDecoder implements Decoder {\n\n    private final Decoder delegate;\n    private final ErrorDecoder errorDecoder;\n\n    public OptionalAwareDecoder(Decoder delegate, ErrorDecoder errorDecoder) {\n        this.delegate = delegate;\n        this.errorDecoder = errorDecoder;\n    }\n\n    @Override\n    public Object decode(Response response, Type type) throws IOException, FeignException {\n        if (response.status() == 404) {\n            if (Types.getRawType(type).equals(Optional.class)) {\n                return Optional.absent();\n            } else {\n                throw Throwables.propagate(errorDecoder.decode(null, response));\n            }\n        } else {\n            return delegate.decode(response, type);\n        }\n    }\n}\n```\n"},"comment":{"url":"https://api.github.com/repos/OpenFeign/feign/issues/comments/268792523","html_url":"https://github.com/OpenFeign/feign/issues/294#issuecomment-268792523","issue_url":"https://api.github.com/repos/OpenFeign/feign/issues/294","id":268792523,"user":{"login":"arielsegura","id":12116053,"avatar_url":"https://avatars.githubusercontent.com/u/12116053?v=3","gravatar_id":"","url":"https://api.github.com/users/arielsegura","html_url":"https://github.com/arielsegura","followers_url":"https://api.github.com/users/arielsegura/followers","following_url":"https://api.github.com/users/arielsegura/following{/other_user}","gists_url":"https://api.github.com/users/arielsegura/gists{/gist_id}","starred_url":"https://api.github.com/users/arielsegura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arielsegura/subscriptions","organizations_url":"https://api.github.com/users/arielsegura/orgs","repos_url":"https://api.github.com/users/arielsegura/repos","events_url":"https://api.github.com/users/arielsegura/events{/privacy}","received_events_url":"https://api.github.com/users/arielsegura/received_events","type":"User","site_admin":false},"created_at":"2016-12-22T12:45:46Z","updated_at":"2016-12-22T12:45:46Z","body":"Yes, I was able to do that but it would be great to include that in feign. I'm going on vacations today but will send a PR when I'm back :)"}}
{"actor":{"display_login":"arielsegura"}}