use of io.servicecomb.common.rest.locator.OperationLocator in project java-chassis by ServiceComb.
the class AbstractRestServer method findRestOperation.
protected RestOperationMeta findRestOperation(RestServerRequestInternal restRequest) {
String selfName = RegistryUtils.getMicroservice().getServiceName();
MicroserviceMeta selfMicroserviceMeta = CseContext.getInstance().getMicroserviceMetaManager().ensureFindValue(selfName);
ServicePathManager servicePathManager = ServicePathManager.getServicePathManager(selfMicroserviceMeta);
if (servicePathManager == null) {
LOGGER.error("No schema in microservice");
throw new InvocationException(Status.NOT_FOUND, Status.NOT_FOUND.getReasonPhrase());
}
OperationLocator locator = servicePathManager.locateOperation(restRequest.getPath(), restRequest.getMethod());
restRequest.setPathParamMap(locator.getPathVarMap());
return locator.getOperation();
}
use of io.servicecomb.common.rest.locator.OperationLocator in project java-chassis by ServiceComb.
the class CseClientHttpRequest method createRequestMeta.
private RequestMeta createRequestMeta(String httpMetod, URI uri) {
String microserviceName = uri.getAuthority();
ReferenceConfig referenceConfig = CseContext.getInstance().getConsumerProviderManager().getReferenceConfig(microserviceName);
MicroserviceMeta microserviceMeta = referenceConfig.getMicroserviceMeta();
ServicePathManager servicePathManager = ServicePathManager.getServicePathManager(microserviceMeta);
if (servicePathManager == null) {
throw new Error(String.format("no schema defined for %s:%s", microserviceMeta.getAppId(), microserviceMeta.getName()));
}
OperationLocator locator = servicePathManager.locateOperation(uri.getPath(), httpMetod);
RestOperationMeta swaggerRestOperation = locator.getOperation();
Map<String, String> pathParams = locator.getPathVarMap();
return new RequestMeta(referenceConfig, swaggerRestOperation, pathParams);
}
Aggregations