public static void buildRestRoutes(RouteBuilder builder, Object bean, IDrinkWaterService drinkWaterService) { //check this for cors problems //http://camel.465427.n5.nabble.com/Workaround-with-REST-DSL-to-avoid-HTTP-method-not-allowed-405-td5771508.html try { String serviceHost = endpointFrom(drinkWaterService); drinkWaterService.getConfiguration().setServiceHost(serviceHost); RestPropertyDefinition corsAllowedHeaders = new RestPropertyDefinition(); corsAllowedHeaders.setKey("Access-Control-Allow-Headers"); corsAllowedHeaders.setValue(getAllowedCorsheaders(drinkWaterService)); // builder.getContext().getDataFormats(); RestConfigurationDefinition restConfig = builder.restConfiguration() .component("jetty") .enableCORS(true) .scheme("http") .host(host(drinkWaterService)) .port(port(drinkWaterService)) .contextPath(context(drinkWaterService, drinkWaterService.getConfiguration())) .bindingMode(RestBindingMode.json) .jsonDataFormat("json-drinkwater"); restConfig.setCorsHeaders(singletonList(corsAllowedHeaders)); } catch (Exception ex) { throw new RuntimeException("could not configure the rest service correctly", ex); } javaslang.collection .List.of(ReflectHelper.getPublicDeclaredMethods(bean.getClass())) .map(method -> buildRestRoute(builder, method, drinkWaterService.getTracer())) .map(tuple -> routeToBeanMethod(tuple._1, bean, tuple._2, drinkWaterService)); }
public Map<String, RestConfigurationDefinition> getRestConfigurations() { return restConfigurations; }
public RestConfigurationDefinition getRestConfiguration() { return restConfiguration; }
public void setRestConfiguration(RestConfigurationDefinition restConfiguration) { this.restConfiguration = restConfiguration; }
@Override public RestConfigurationDefinition getRestConfiguration() { return _factoryBean.getRestConfiguration(); }
/** * Configures the REST services * * @return the builder */ public RestConfigurationDefinition restConfiguration() { return restConfiguration(""); }
public abstract RestConfigurationDefinition getRestConfiguration();