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

org.bitbucket.gkutiel.in.my.mind.dispatcher.Dispatcher Maven / Gradle / Ivy

The newest version!
package org.bitbucket.gkutiel.in.my.mind.dispatcher;

import static java.lang.Class.forName;
import org.bitbucket.gkutiel.in.Handler;
import io.reactivex.netty.protocol.http.server.HttpServerRequest;

public class Dispatcher implements org.bitbucket.gkutiel.in.Dispatcher {

	static String className(final String path) {
		return "www" + ("/" + path + "/").replaceAll("/+", ".") + "Index";
	}

	@Override public Handler handler(final HttpServerRequest req) {
		try {
			return (Handler) forName(className(req.getPath())).newInstance();
		} catch (final Exception e) {
			throw new RuntimeException(e);
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy