use of com.tvd12.ezyhttp.server.core.exception.DuplicateURIMappingHandlerException in project ezyhttp by youngmonkeys.
the class RequestHandlerManager method addHandler.
public void addHandler(RequestURI uri, RequestHandler handler) {
RequestHandler old = this.handlers.put(uri, handler);
if (old != null && !allowOverrideURI) {
throw new DuplicateURIMappingHandlerException(uri, old, handler);
}
this.handledURIs.add(uri.getUri());
this.logger.info("add mapping uri: {}", uri);
this.handlerListByURI.computeIfAbsent(uri, k -> new ArrayList<>()).add(handler);
this.requestURIManager.addHandledURI(uri.getMethod(), uri.getUri());
if (uri.isApi()) {
this.requestURIManager.addApiURI(uri.getMethod(), uri.getUri());
this.requestURIManager.addApiURI(uri.getMethod(), uri.getSameURI());
}
if (uri.isAuthenticated()) {
this.requestURIManager.addAuthenticatedURI(uri.getMethod(), uri.getUri());
this.requestURIManager.addAuthenticatedURI(uri.getMethod(), uri.getSameURI());
}
if (uri.isManagement()) {
this.requestURIManager.addManagementURI(uri.getMethod(), uri.getUri());
this.requestURIManager.addManagementURI(uri.getMethod(), uri.getSameURI());
}
if (uri.isPayment()) {
this.requestURIManager.addPaymentURI(uri.getMethod(), uri.getUri());
this.requestURIManager.addPaymentURI(uri.getMethod(), uri.getSameURI());
}
if (EzyStrings.isNotBlank(uri.getFeature())) {
this.featureURIManager.addFeatureURI(uri.getFeature(), uri.getMethod(), uri.getUri());
this.featureURIManager.addFeatureURI(uri.getFeature(), uri.getMethod(), uri.getSameURI());
}
URITree uriTree = uriTreeByMethod.get(uri.getMethod());
uriTree.addURI(uri.getUri());
}
Aggregations