public WarehouseRoute(Warehouse warehouse, RestxSecurityManager securityManager, PermissionFactory permissionFactory) { super("WarehouseRoute", new StdRestxRequestMatcher("GET", "/@/warehouse")); this.warehouse = warehouse; this.securityManager = securityManager; this.permissionFactory = permissionFactory; }
public JsonLabelsRoute(Messages messages, CurrentLocaleResolver currentLocaleResolver) { super("labels.json", new StdRestxRequestMatcher("GET", "/i18n/labels.json")); this.messages = messages; this.currentLocaleResolver = currentLocaleResolver; }
@Inject public FactoryDumpRoute(Factory factory, RestxSecurityManager securityManager, final PermissionFactory permissionFactory) { super("FactoryRoute", new StdRestxRequestMatcher("GET", "/@/factory")); this.factory = factory; this.securityManager = securityManager; this.permissionFactory = permissionFactory; }
public JsLabelsRoute(Messages messages, String labelsJsTemplate, CurrentLocaleResolver currentLocaleResolver) { super("labels.js", new StdRestxRequestMatcher("GET", "/i18n/labels.js")); this.messages = messages; this.currentLocaleResolver = currentLocaleResolver; int i = labelsJsTemplate.indexOf("{LABELS}"); if (i == -1) { throw new IllegalArgumentException("invalid labels js template. It must have {LABELS} token inside." + "\n\tIt was :'" + labelsJsTemplate + "'"); } labelsJsBefore = labelsJsTemplate.substring(0, i); labelsJsAfter = labelsJsTemplate.substring(i + "{LABELS}".length()); }
public GzipFilter(HttpSettings httpSettings) { ImmutableList.Builder<RestxRequestMatcher> builder = ImmutableList.builder(); for (String path : httpSettings.gzipPaths()) { builder.add(new StdRestxRequestMatcher("GET", path)); } matchers = builder.build(); }
public GzipFilter(HttpSettings httpSettings) { ImmutableList.Builder<RestxRequestMatcher> builder = ImmutableList.builder(); for (String path : httpSettings.gzipPaths()) { builder.add(new StdRestxRequestMatcher("GET", path)); } matchers = builder.build(); }
super("SpecRecorderRouter", new ResourcesRoute("RecorderUIRoute", "/@/ui/recorder/", "restx.specs.recorder", ImmutableMap.of("", "index.html")), new StdRoute("RecorderRoute", new StdRestxRequestMatcher("GET", "/@/recorders")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { new StdRoute("RecorderRecord", new StdRestxRequestMatcher("GET", "/@/recorders/{id}")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { new StdRoute("RecorderRecordStorage", new StdRestxRequestMatcher("POST", "/@/recorders/storage/{id}")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException {
super("SpecRecorderRouter", new ResourcesRoute("RecorderUIRoute", "/@/ui/recorder/", "restx.specs.recorder", ImmutableMap.of("", "index.html")), new StdRoute("RecorderRoute", new StdRestxRequestMatcher("GET", "/@/recorders")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { new StdRoute("RecorderRecord", new StdRestxRequestMatcher("GET", "/@/recorders/{id}")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { new StdRoute("RecorderRecordStorage", new StdRestxRequestMatcher("POST", "/@/recorders/storage/{id}")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException {
public StdEntityRoute(String name, EntityRequestBodyReader<I> entityRequestBodyReader, EntityResponseWriter<O> entityResponseWriter, Endpoint endpoint, HttpStatus successStatus, RestxLogLevel logLevel, PermissionFactory permissionFactory, EndpointParameterMapperRegistry registry, ParamDef[] queryParametersDefinition ) { super(name, new StdRestxRequestMatcher(endpoint), successStatus); this.endpoint = endpoint; this.permissionFactory = permissionFactory; this.entityRequestBodyReader = checkNotNull(entityRequestBodyReader); this.entityResponseWriter = checkNotNull(entityResponseWriter); this.logLevel = checkNotNull(logLevel); this.cachedQueryParameterMappers = cacheQueryParameterMappers(registry, endpoint, queryParametersDefinition); }
final MetricRegistry metrics = codahaleMetricRegistry.getCodahaleMetricRegistry(); return new StdRoute("MonitorRoute", new StdRestxRequestMatcher("GET", "/@/monitor")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException {
public StdEntityRoute(String name, EntityRequestBodyReader<I> entityRequestBodyReader, EntityResponseWriter<O> entityResponseWriter, Endpoint endpoint, HttpStatus successStatus, RestxLogLevel logLevel, PermissionFactory permissionFactory, EndpointParameterMapperRegistry registry, ParamDef[] queryParametersDefinition ) { super(name, new StdRestxRequestMatcher(endpoint), successStatus); this.endpoint = endpoint; this.permissionFactory = permissionFactory; this.entityRequestBodyReader = checkNotNull(entityRequestBodyReader); this.entityResponseWriter = checkNotNull(entityResponseWriter); this.logLevel = checkNotNull(logLevel); this.cachedQueryParameterMappers = cacheQueryParameterMappers(registry, endpoint, queryParametersDefinition); }
final MetricRegistry metrics = codahaleMetricRegistry.getCodahaleMetricRegistry(); return new StdRoute("MonitorRoute", new StdRestxRequestMatcher("GET", "/@/monitor")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException {
Iterable<String> filterSpecsByOperation(ImmutableMap<String, RestxSpec> allSpecs, String httpMethod, String path) { StdRestxRequestMatcher matcher = new StdRestxRequestMatcher(httpMethod, path); Collection<String> specs = Lists.newArrayList(); for (Map.Entry<String, RestxSpec> spec : allSpecs.entrySet()) { for (When when : spec.getValue().getWhens()) { if (when instanceof WhenHttpRequest) { WhenHttpRequest request = (WhenHttpRequest) when; String requestPath = request.getPath(); if (!requestPath.startsWith("/")) { requestPath = "/" + requestPath; } if (requestPath.indexOf("?") != -1) { requestPath = requestPath.substring(0, requestPath.indexOf("?")); } Optional<? extends RestxRequestMatch> match = matcher.match(request.getMethod(), requestPath); if (match.isPresent()) { specs.add(spec.getKey()); break; } } } } return specs; }
Iterable<String> filterSpecsByOperation(ImmutableMap<String, RestxSpec> allSpecs, String httpMethod, String path) { StdRestxRequestMatcher matcher = new StdRestxRequestMatcher(httpMethod, path); Collection<String> specs = Lists.newArrayList(); for (Map.Entry<String, RestxSpec> spec : allSpecs.entrySet()) { for (When when : spec.getValue().getWhens()) { if (when instanceof WhenHttpRequest) { WhenHttpRequest request = (WhenHttpRequest) when; String requestPath = request.getPath(); if (!requestPath.startsWith("/")) { requestPath = "/" + requestPath; } if (requestPath.indexOf("?") != -1) { requestPath = requestPath.substring(0, requestPath.indexOf("?")); } Optional<? extends RestxRequestMatch> match = matcher.match(request.getMethod(), requestPath); if (match.isPresent()) { specs.add(spec.getKey()); break; } } } } return specs; }
.addRoute(new StdRoute("FS:GET:" + fsPath, new StdRestxRequestMatcher("GET", onPath + "{path:.*}")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) builder.addRoute(new StdRoute("FS:PUT:" + fsPath, new StdRestxRequestMatcher("PUT", onPath + "{path:.*}")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) builder.addRoute(new StdRoute("FS:DELETE:" + fsPath, new StdRestxRequestMatcher("DELETE", onPath + "{path:.*}")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx)
.addRoute(new StdRoute("FS:GET:" + fsPath, new StdRestxRequestMatcher("GET", onPath + "{path:.*}")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) builder.addRoute(new StdRoute("FS:PUT:" + fsPath, new StdRestxRequestMatcher("PUT", onPath + "{path:.*}")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) builder.addRoute(new StdRoute("FS:DELETE:" + fsPath, new StdRestxRequestMatcher("DELETE", onPath + "{path:.*}")) { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx)
StdRestxRequestMatcher requestMatcher = new StdRestxRequestMatcher(httpMethod, path); pathParamNames = requestMatcher.getPathParamNames();