Skip to content

Instantly share code, notes, and snippets.

@fiunchinho
Last active August 16, 2016 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fiunchinho/7ff3dcda089ffbe19d42359a92396650 to your computer and use it in GitHub Desktop.
Save fiunchinho/7ff3dcda089ffbe19d42359a92396650 to your computer and use it in GitHub Desktop.
Endpoint that returns 400 Bad requests when coming from Zuul
@RequestMapping(value = "/endpoint", method = RequestMethod.PUT, produces = "application/json")
public Single<String> sayHello(HttpServletResponse response) throws IOException {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("payload_big.json");
Observable<String> sobs = Observable.create(new Observable.OnSubscribe<String>() {
@Override
public void call(Subscriber<? super String> subscriber) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
String line;
while((line= br.readLine())!=null) {
subscriber.onNext(line);
}
} catch (Exception e) {
subscriber.onError(e.getCause());
} finally {
subscriber.onCompleted();
}
}
});
return sobs.first().toSingle();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment