All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clouway.friendlyserve.TkFork Maven / Gradle / Ivy

There is a newer version: 0.1.5
Show newest version
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);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy