class WebDispatch {

	public WebResponse dispatch(WebRequest request) {
		try {
			for (Entry<WebPath, Handler> handlerEntry : pathToHandler.entrySet()) {
				WebPath webPath = handlerEntry.getKey();
				MatchResult match = webPath.match(request.getHttpMethod(), request.getPath());
				if (match.matches()) {
					return invoker.invoke(request, match, handlerEntry.getValue());
				}
			}
			return notFound(request);
		} catch (Exception e) { // fault barrier
			logger.log(Level.SEVERE, format("Unexpected exception: {0}", e.getMessage()), e);
			return invoker.toWebResponse(e);
		}
	}

	@Inject public  WebDispatch(Injector injector, Invoker invoker, Logger logger);

}