本文整理汇总了Java中ratpack.handling.Handler类的典型用法代码示例。如果您正苦于以下问题:Java Handler类的具体用法?Java Handler怎么用?Java Handler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Handler类属于ratpack.handling包,在下文中一共展示了Handler类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Route
import ratpack.handling.Handler; //导入依赖的package包/类
public Route(final Resource resource, final Method method) {
final Registry registry = Registry.builder().add(resource).add(method).build();
final Handler chain = Handlers.chain(
RequestLogger.ncsa(LOG),
requestValidationHandler,
Handlers.when(isMode(VrapMode.proxy),
Handlers.chain(
requestProxyHandler,
receivedResponseValidationHandler,
receivedResponseForwardHandler)),
Handlers.when(isMode(VrapMode.example), requestExampleHandler));
this.delegate = Handlers.register(registry, chain);
}
示例2: RamlHandler
import ratpack.handling.Handler; //导入依赖的package包/类
public RamlHandler(FileContentModifier contentModifier) {
final Registry registry = Registry.builder().add("get").build();
final Handler chain = Handlers.chain(
RequestLogger.ncsa(LOG),
Handlers.when(
isJsonFile(),
new JsonFileHandler(contentModifier)
),
new RamlFileHandler(contentModifier)
);
this.delegate = Handlers.register(registry, chain);
}
示例3: createRoutes
import ratpack.handling.Handler; //导入依赖的package包/类
private List<Handler> createRoutes(final List<SecurityScheme> schemes) throws Exception {
final List<Handler> routes = new ArrayList<>();
for (final SecurityScheme scheme : schemes) {
routes.add(Handlers.prefix(
scheme.name(),
new Route(scheme.settings().accessTokenUri().value())
));
}
return routes;
}
示例4: Route
import ratpack.handling.Handler; //导入依赖的package包/类
public Route(final String authUri) {
requestProxyHandler = new AuthRouter.RequestProxyHandler(authUri);
final Registry registry = Registry.builder().add(authUri).build();
final Handler chain = Handlers.chain(
RequestLogger.ncsa(LOG),
requestProxyHandler
);
this.delegate = Handlers.register(registry, chain);
}
示例5: doAuthorized
import ratpack.handling.Handler; //导入依赖的package包/类
/**
* executes the consumer if the client is authorized
* @param contextConsumer the consumer to execute
* @return a handler that executes the consumer if authorized
*/
private Handler doAuthorized(Consumer<Context> contextConsumer) {
return ctx -> {
ctx.maybeGet(WorkerID.class)
.orElseThrow(() -> new UnauthorizedException("Client needs the Authorization-header to acces the method"));
contextConsumer.accept(ctx);
};
}
示例6: getRoutes
import ratpack.handling.Handler; //导入依赖的package包/类
public Handler getRoutes() {
return routes;
}
示例7: createRoutes
import ratpack.handling.Handler; //导入依赖的package包/类
private List<Handler> createRoutes(final Api api) throws Exception {
return createRoutes(api, api.resources());
}
示例8: getHandler
import ratpack.handling.Handler; //导入依赖的package包/类
public Handler getHandler() {
return handler;
}
示例9: SoapActionHandler
import ratpack.handling.Handler; //导入依赖的package包/类
public SoapActionHandler(String soapAction, Handler handler) {
this.soapAction = soapAction;
this.handler = handler;
}
示例10: fromHandler
import ratpack.handling.Handler; //导入依赖的package包/类
/**
* Creates an embedded application with a default launch config (no base dir, ephemeral port) and the given handler.
* <p>
* If you need to tweak the launch config, use {@link #fromLaunchConfigBuilder(Function)}.
*
* @param handler the application handler
* @return a newly created embedded application
*/
static EmbeddedApp fromHandler(Handler handler) {
return fromLaunchConfigBuilder(lcb -> lcb.build(lc -> handler));
}