@Override public Pipe<ServerResponseSchema>[] registerModule(int a, GraphManager graphManager, RouterStageConfig routerConfig, Pipe<HTTPRequestSchema>[] inputPipes) { //the file server is stateless therefore we can build 1 instance for every input pipe int instances = inputPipes.length; Pipe<ServerResponseSchema>[] staticFileOutputs = new Pipe[instances]; int i = instances; while (--i>=0) { staticFileOutputs[i] = new Pipe<ServerResponseSchema>(fileServerOutgoingDataConfig); FileReadModuleStage.newInstance(graphManager, inputPipes[i], staticFileOutputs[i], (HTTPSpecification<HTTPContentTypeDefaults, HTTPRevisionDefaults, HTTPVerbDefaults, HTTPHeaderDefaults>) ((HTTPRouterStageConfig)routerConfig).httpSpec, new File(pathRoot)); } routerConfig.registerCompositeRoute().path("/${path}"); //no headers requested return staticFileOutputs; }
public RouteFilter addFileServer(String path) { //adds server to all routes final int parallelIndex = (-1 == parallelInstanceUnderActiveConstruction) ? 0 : parallelInstanceUnderActiveConstruction; //due to internal implementation we must keep the same number of outputs as inputs. Pipe<HTTPRequestSchema>[] inputs = new Pipe[1]; Pipe<ServerResponseSchema>[] outputs = new Pipe[1]; populateHTTPInOut(inputs, outputs, 0, parallelIndex); FileReadModuleStage.newInstance(gm, inputs, outputs, builder.httpSpec, buildFilePath(path)); return new StageRouteFilter(inputs[0], builder, parallelIndex); }
if (null != pathRoot) { FileReadModuleStage.newInstance(graphManager, inputPipes[i], staticFileOutputs[i], (HTTPSpecification<HTTPContentTypeDefaults, HTTPRevisionDefaults, HTTPVerbDefaults, HTTPHeaderDefaults>) ((HTTPRouterStageConfig)routerConfig).httpSpec, pathRoot); } else {