com.clouway.friendlyserve.TkFork Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fserve Show documentation
Show all versions of fserve Show documentation
Friendly Serving HTTP Library.
package com.clouway.friendlyserve;
import com.google.common.base.Optional;
import java.io.IOException;
import java.net.HttpURLConnection;
/**
* @author Miroslav Genov ([email protected])
*/
public class TkFork implements Take {
private transient final Fork[] forks;
public TkFork(Fork... forks) {
this.forks = forks;
}
@Override
public Response ack(Request request) throws IOException {
for (Fork each : forks) {
Optional possibleResponse = each.route(request);
if (possibleResponse.isPresent()) {
return possibleResponse.get();
}
}
throw new HttpException(HttpURLConnection.HTTP_NOT_FOUND);
}
}