@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
@Override public Optional<RestxHandlerMatch> match(RestxRoute route) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("/*"), this)); }
protected Optional<RestxHandlerMatch> unauthorized(RestxRequest req) { return Optional.of( new RestxHandlerMatch(new StdRestxRequestMatch("*", req.getRestxPath(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of()), UNAUTHORIZED_HANDLER)); } }
@Override public Optional<RestxHandlerMatch> match(RestxRequest req) { return Optional.of(new RestxHandlerMatch( new StdRestxRequestMatch("*", req.getRestxPath()), new RestxHandler() { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { throw new WebException(HttpStatus.NOT_FOUND); } } )); } };
protected Optional<RestxHandlerMatch> unauthorized(RestxRequest req) { return Optional.of( new RestxHandlerMatch(new StdRestxRequestMatch("*", req.getRestxPath(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of()), UNAUTHORIZED_HANDLER)); } }
@Override public Optional<RestxHandlerMatch> match(RestxRequest req) { return Optional.of(new RestxHandlerMatch( new StdRestxRequestMatch("*", req.getRestxPath()), new RestxHandler() { @Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { throw new WebException(HttpStatus.NOT_FOUND); } } )); } };
@Override public Optional<? extends RestxRequestMatch> match(String method, String path) { if (!this.endpoint.getMethod().equals(method)) { return Optional.absent(); } Matcher m = pattern.matcher(path); if (!m.matches()) { return Optional.absent(); } ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); for (int i = 0; i < m.groupCount() && i < groupNames.size(); i++) { params.put(groupNames.get(i), m.group(i + 1)); } return Optional.of(new StdRestxRequestMatch(this.endpoint.getPathPattern(), path, params.build())); }
@Override public Optional<RestxHandlerMatch> match(RestxRequest req) { Optional<String> authorization = req.getHeader("Authorization"); if (authorization.isPresent()) { if (authorization.get().toLowerCase(Locale.ENGLISH).startsWith("basic ")) { return Optional.of(new RestxHandlerMatch( new StdRestxRequestMatch("*", req.getRestxPath()), basicHandler)); } else { logger.warn("unsupported authentication type: " + authorization.get()); } } return Optional.absent(); }
@Override public Optional<? extends RestxRequestMatch> match(String method, String path) { if (!this.endpoint.getMethod().equals(method)) { return Optional.absent(); } Matcher m = pattern.matcher(path); if (!m.matches()) { return Optional.absent(); } ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); for (int i = 0; i < m.groupCount() && i < groupNames.size(); i++) { params.put(groupNames.get(i), m.group(i + 1)); } return Optional.of(new StdRestxRequestMatch(this.endpoint.getPathPattern(), path, params.build())); }
@Override public Optional<RestxHandlerMatch> match(RestxRequest req) { Optional<String> authorization = req.getHeader("Authorization"); if (authorization.isPresent()) { if (authorization.get().toLowerCase(Locale.ENGLISH).startsWith("basic ")) { return Optional.of(new RestxHandlerMatch( new StdRestxRequestMatch("*", req.getRestxPath()), basicHandler)); } else { logger.warn("unsupported authentication type: " + authorization.get()); } } return Optional.absent(); }
@Override public Optional<RestxHandlerMatch> match(RestxRequest req) { if (req.getHttpMethod().equals("GET") && req.getRestxPath().startsWith(baseRestPath)) { return Optional.of(new RestxHandlerMatch( new StdRestxRequestMatch(baseRestPath + "*", req.getRestxPath()), this)); } else { return Optional.absent(); } }
@Override public Optional<RestxHandlerMatch> match(RestxRequest req) { if (req.getHttpMethod().equals("GET") && req.getRestxPath().startsWith(baseRestPath)) { return Optional.of(new RestxHandlerMatch( new StdRestxRequestMatch(baseRestPath + "*", req.getRestxPath()), this)); } else { return Optional.absent(); } }
@Override public Optional<RestxHandlerMatch> match(RestxRequest req) { Optional<String> acrMethod = req.getHeader("Access-Control-Request-Method"); if ("OPTIONS".equals(req.getHttpMethod()) && acrMethod.isPresent()) { Optional<String> origin = req.getHeader("Origin"); CORS cors = CORS.check(authorizers, req, origin.get(), acrMethod.get(), req.getRestxPath()); if (cors.isAccepted()) { return Optional.of(new RestxHandlerMatch(new StdRestxRequestMatch("*", req.getRestxPath(), ImmutableMap.<String, String>of(), ImmutableMap.of("cors", cors)), this)); } else { logger.info("Unauthorized pre-flight CORS request; Origin={}; Method={}", origin.get(), acrMethod.get()); return unauthorized(req); } } return Optional.absent(); }