本文整理汇总了Java中ratpack.handling.Context.next方法的典型用法代码示例。如果您正苦于以下问题:Java Context.next方法的具体用法?Java Context.next怎么用?Java Context.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ratpack.handling.Context
的用法示例。
在下文中一共展示了Context.next方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import ratpack.handling.Context; //导入方法依赖的package包/类
@Override
public void handle(final Context ctx) throws Exception {
final PathBinding pathBinding = ctx.getPathBinding();
final String path = pathBinding.getPastBinding();
final String resourePathStr = Joiner.on("/").join(WEBJAR_ROOT, moduleName, version, includePath, path);
final Path resourcePath = jarFileSystem.isPresent() ?
jarFileSystem.map(fs -> fs.getPath(resourePathStr)).get() :
ctx.getFileSystemBinding().file(resourePathStr);
if (Files.exists(resourcePath)) {
ctx.render(resourcePath);
} else {
ctx.next();
}
}
示例2: handle
import ratpack.handling.Context; //导入方法依赖的package包/类
@Override
public void handle(final Context ctx) throws Exception {
final RamlModelRepository ramlModelRepository = ctx.get(RamlModelRepository.class);
final Path filePath = ramlModelRepository.getFilePath();
final PathBinding pathBinding = ctx.getPathBinding();
final String path = pathBinding.getPastBinding();
if (path.isEmpty() || path.equals("index.html")) {
final String queryParams = QueryParams.queryParams(ctx);
final Integer port = ctx.getServerConfig().getPort();
final String jsonFileName = filePath.toAbsolutePath().toString().replaceAll("raml$", "json");
final File jsonFile = new File(jsonFileName);
final ImmutableMap<String, Object> model =
ImmutableMap.of(
"ramlPath", "api-raml/Vrap-Extension.raml",
"queryParams", queryParams,
"proxyHost", "localhost",
"proxyPort", port,
"jsonFile", jsonFile.exists() ? "/api-raml/" + jsonFile.getName() : ""
);
ctx.render(handlebarsTemplate(model, basePath + "/index.html"));
}
else {
ctx.next();
}
}
示例3: handle
import ratpack.handling.Context; //导入方法依赖的package包/类
/**
* Runs actions with the given {@code pattern}
*
* @param ctx the request context
* @throws Exception any
*/
@Override
public void handle(Context ctx) throws Exception {
ctx.getResponse().getHeaders()
.add("Cache-Control", "no-cache, no-store, must-revalidate")
.add("Pragma", "no-cache")
.add("Expires", "0");
String patternName = ctx.getPathTokens().get(DEFAULT_NAME_TOKEN);
if (patternName == null || "".equals(patternName)) {
ctx.clientError(404);
return;
}
if (FanOutFanIn.PATTERN_NAME.equals(patternName)) {
ctx.insert(fanOutFanInHandler);
} else if (Parallel.PATTERN_NAME.equals(patternName)) {
ctx.insert(parallelHandler);
} else if (InvokeWithRetry.PATTERN_NAME.equals(patternName)) {
ctx.insert(invokeAndRetryHandler);
} else {
ctx.next();
}
}
示例4: handle
import ratpack.handling.Context; //导入方法依赖的package包/类
@Override
public void handle(final Context ctx) throws Exception {
final RamlModelRepository ramlModelRepository = ctx.get(RamlModelRepository.class);
final Api api = ramlModelRepository.getApi();
final String path = ctx.getPathBinding().getPastBinding();
if (path.equals("Vrap-Extension.raml")) {
final Path filePath = ramlModelRepository.getFilePath();
List<ResourceExtension> resourceExtensions = resourceExtensions(api.resources(), "");
final Integer port = ctx.getServerConfig().getPort();
final String authProxyUri = "http://localhost:" + port.toString() + "/auth";
final String proxyUri = "http://localhost:" + port.toString() + "/" + apiUri + new URI(api.baseUri().value().replace("{", "%7B").replace("}", "%7D")).getPath().replace("%7B", "{").replace("%7D", "}");
List<SecurityScheme> oauthSchemes = api.securitySchemes().stream().filter(securityScheme -> securityScheme.type().equals("OAuth 2.0")).collect(Collectors.toList());
final ImmutableMap<String, Object> model =
ImmutableMap.<String, Object>builder()
.put("fileName", filePath.getFileName())
.put("queryParams", ctx.getRequest().getQuery())
.put("resourceExtensions", resourceExtensions)
.put("proxyUri", proxyUri)
.put("modes", Joiner.on(", ").join(VrapMode.values()))
.put("flags", Joiner.on(", ").join(ValidationFlag.values()))
.put("authProxyUri", authProxyUri)
.put("oauthSchemes", oauthSchemes.stream().map(securityScheme -> securityScheme.name()).collect(Collectors.toList()))
.build();
ctx.byContent(byContentSpec -> byContentSpec
.type("application/raml+yaml", () -> ctx.render(handlebarsTemplate(model, "api-raml/Vrap-Extension.raml")))
.html(() -> ctx.render(handlebarsTemplate(model, "api-raml/Vrap-Extension.html")))
.noMatch("application/raml+yaml"));
} else {
ctx.next();
}
}
示例5: validateRequest
import ratpack.handling.Context; //导入方法依赖的package包/类
private void validateRequest(final Context ctx, final TypedData body) throws Exception {
final Validator validator = ctx.get(Validator.class);
final boolean dryRun = ctx.get(VrapApp.VrapOptions.class).getDryRun();
final Method method = ctx.get(Method.class);
final Optional<Validator.ValidationErrors> validationErrors = validator.validateRequest(ctx, body, method);
ctx.next(Registry.of(registrySpec -> {
registrySpec.add(TypedData.class, body);
validationErrors.ifPresent(validationErrors1 -> registrySpec.add(Validator.ValidationErrors.class, validationErrors1));
}));
}
示例6: handle
import ratpack.handling.Context; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void handle(Context ctx) throws Exception {
final ReceivedResponse receivedResponse = ctx.get(ReceivedResponse.class);
final Validator validator = ctx.get(Validator.class);
final Boolean dryRun = ctx.get(VrapApp.VrapOptions.class).getDryRun();
final Method method = ctx.get(Method.class);
final Optional<Validator.ValidationErrors> receivedResponseErrors = validator.validateReceivedResponse(ctx, receivedResponse, method);
Optional<Validator.ValidationErrors> requestValidationErrors;
try {
requestValidationErrors = Optional.of(ctx.get(Validator.ValidationErrors.class));
} catch (NotInRegistryException e) {
requestValidationErrors = Optional.empty();
}
if (requestValidationErrors.isPresent() && !dryRun) {
Integer statusCode = receivedResponse.getStatusCode();
if (statusCode < 400 && statusCode > 499) {
ctx.getResponse().status(VrapStatus.INVALID_REQUEST);
Validator.ValidationErrors errors = new Validator.ValidationErrors(
requestValidationErrors.get().getErrors(),
receivedResponse.getStatusCode(),
receivedResponse.getBody().getText());
ctx.render(json(errors));
return;
}
}
if (receivedResponseErrors.isPresent() && !dryRun) {
ctx.getResponse().status(VrapStatus.INVALID_RESPONSE);
ctx.render(json(receivedResponseErrors.get()));
} else {
ctx.next();
}
}
示例7: handle
import ratpack.handling.Context; //导入方法依赖的package包/类
@Override
public void handle(Context ctx) throws Exception {
String soapAction = ctx.getRequest().getHeaders().get("SOAPAction");
if (this.soapAction.equals(soapAction)) {
ctx.insert(this.handler);
} else {
ctx.next();
}
}
示例8: handle
import ratpack.handling.Context; //导入方法依赖的package包/类
@Override
public void handle(Context ctx) throws Exception {
ServerRequest request = new ServerRequestImpl(ctx.getRequest());
final Span span = handler.handleReceive(extractor, request);
//place the Span in scope so that downstream code (e.g. Ratpack handlers
//further on in the chain) can see the Span.
final Tracer.SpanInScope scope = tracing.tracer().withSpanInScope(span);
ctx.getResponse().beforeSend(response -> {
ServerResponse serverResponse = new ServerResponseImpl(response, request, ctx.getPathBinding());
handler.handleSend(serverResponse, null, span);
scope.close();
});
ctx.next();
}
示例9: handle
import ratpack.handling.Context; //导入方法依赖的package包/类
@Override
public void handle(Context ctx) throws Exception {
Duration timeoutDuration = rateLimiter.getRateLimiterConfig().getTimeoutDuration();
boolean permission = rateLimiter.getPermission(timeoutDuration);
if (Thread.interrupted()) {
throw new IllegalStateException("Thread was interrupted during permission wait");
}
if (!permission) {
Throwable t = new RequestNotPermitted("Request not permitted for limiter: " + rateLimiter.getName());
ctx.error(t);
} else {
ctx.next();
}
}
示例10: handle
import ratpack.handling.Context; //导入方法依赖的package包/类
@Override
public void handle(Context ctx) throws Exception {
// TODO handle soapAction if matches incoming soapAction
ctx.next();
}