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

com.clouway.friendlyserve.RequestHandlerMatchingParam 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;

/**
 * RequestHandlerMatchingParam is an optional handler which could handle request only if the requested param is matching
 * the provided value.
 *
 * 

An absent value will be returned when parameter value is not matching. * * @author Miroslav Genov ([email protected]) */ public class RequestHandlerMatchingParam implements Fork { private final String key; private final String value; private final Take take; public RequestHandlerMatchingParam(String key, String value, Take take) { this.key = key; this.value = value; this.take = take; } @Override public Optional route(Request request) throws IOException { String param = request.param(key); if (value.equals(param)) { return Optional.of(take.ack(request)); } return Optional.absent(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy