use of in.erail.service.RESTService in project api-framework by vinscom.
the class OpenAPI3RouteBuilder method getRouter.
@Override
public Router getRouter(Router pRouter) {
OpenAPI3RouterFactory apiFactory = OpenAPI3RouterFactory.rxCreateRouterFactoryFromFile(getVertx(), getOpenAPI3File().getAbsolutePath()).blockingGet();
getServices().getServices().forEach((api) -> {
RESTService service = (RESTService) api;
apiFactory.addHandlerByOperationId(service.getOperationId(), (routingContext) -> {
routingContext.put(FrameworkConstants.RoutingContext.Attribute.BODY_AS_JSON, service.isBodyAsJson());
if (isSecurityEnable()) {
if (routingContext.user() == null) {
routingContext.fail(401);
return;
}
routingContext.user().isAuthorized(AUTHORIZATION_PREFIX + ":" + service.getOperationId(), (event) -> {
boolean authSuccess = event.succeeded() ? event.result() : false;
if (authSuccess) {
process(routingContext, service.getServiceUniqueId());
} else {
routingContext.fail(401);
}
});
} else {
getLog().warn("Security disabled for " + service.getServiceUniqueId());
process(routingContext, service.getServiceUniqueId());
}
});
});
return apiFactory.getRouter();
}
use of in.erail.service.RESTService in project api-framework by vinscom.
the class OpenAPI3RouteBuilder method start.
@StartService
public void start() {
getServices().getServices().stream().forEach((api) -> {
RESTService service = (RESTService) api;
getMetricTimers().put(service.getServiceUniqueId(), getMetricRegistry().timer("api.framework.service." + service.getServiceUniqueId()));
});
}
Aggregations