use of com.datastax.fallout.service.artifacts.NginxArtifactServlet in project fallout by datastax.
the class FalloutServiceBase method addArtifactServlet.
private static void addArtifactServlet(FalloutConfiguration conf, Environment environment, RewriteHandler rewriteHandler) {
Function<Path, Servlet> createArtifactServlet = conf.useNginxToServeArtifacts() ? NginxArtifactServlet::new : JettyArtifactServlet::new;
final ServletRegistration.Dynamic registration = environment.servlets().addServlet("artifacts-servlet", createArtifactServlet.apply(Paths.get(conf.getArtifactPath())));
registration.addMapping("/artifacts/*");
// Redirect direct requests to the artifacts servlet URL to make sure users see (and share) the right path
// in the browser; fallout used to make these URLs public, so some will have been shared in tickets etc.,
// which means we should carry on handling them.
rewriteHandler.addRule(new RedirectRegexRule("/artifacts/" + "(" + AccountResource.EMAIL_PATTERN + ")/" + "(" + TestResource.NAME_PATTERN + ")/" + "(" + TestResource.ID_PATTERN + ")/" + "(.*)", "/tests/ui/$1/$2/$3/artifacts/$4"));
// Rewrite artifacts requests so that they're handled by the artifacts servlet
rewriteHandler.addRule(new RewriteRegexRule("/tests/ui/" + "(" + AccountResource.EMAIL_PATTERN + ")/" + "(" + TestResource.NAME_PATTERN + ")/" + "(" + TestResource.ID_PATTERN + ")/" + "artifacts/(.+)", "/artifacts/$1/$2/$3/$4"));
environment.servlets().addMimeMapping("log", "text/plain; charset=UTF-8");
}
Aggregations