本文整理汇总了Java中ratpack.handling.Chain类的典型用法代码示例。如果您正苦于以下问题:Java Chain类的具体用法?Java Chain怎么用?Java Chain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Chain类属于ratpack.handling包,在下文中一共展示了Chain类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import ratpack.handling.Chain; //导入依赖的package包/类
@Override
public void init() {
try {
RatpackServer.start(server -> {
server.serverConfig(c -> {
for(Action<ServerConfigBuilder> cfg : getConfigurators()) {
c = cfg.with(c);
}
});
server.registry(Guice.registry(b -> {
for(Action<BindingsSpec> binding : getBindings()) {
b = binding.with(b);
}
}));
server.handlers(chain -> {
for(Action<Chain> handler : getHandlers()) {
// chain = chain.insert(handler);
chain = handler.with(chain);
}
});
});
} catch (Exception e) {
logger.error("Ratpack failure", e);
}
}
开发者ID:beryx,项目名称:text-io,代码行数:26,代码来源:RatpackDataServer.java
示例2: BaseServer
import ratpack.handling.Chain; //导入依赖的package包/类
public BaseServer(Action<Chain> handlers, ServerConfig config, Action<BindingsSpec> binding) throws ServerException {
try {
this.ratpackServer = RatpackServer.of(def ->
def.serverConfig(config)
.registry(Guice.registry(binding))
.handlers(handlers));
} catch (Exception e) {
throw new ServerException("Error in building ratpack server.", e);
}
}
开发者ID:masgari,项目名称:microservices-sample,代码行数:11,代码来源:BaseServer.java
示例3: execute
import ratpack.handling.Chain; //导入依赖的package包/类
@Override
public void execute(Chain chain) throws Exception {
//handle all requests to /users
chain.prefix(UsersCollectionHandler.COLLECTION_NAME, chain.getRegistry().get(UsersCollectionHandler.class))
//default handler, show REST endpoints
.handler(ctx -> ctx.render("Users Service - list users: 'GET /v1/users' "));
}
开发者ID:masgari,项目名称:microservices-sample,代码行数:8,代码来源:UserHandlerFactory.java
示例4: execute
import ratpack.handling.Chain; //导入依赖的package包/类
@Override
public void execute(Chain chain) throws Exception {
chain
//connections is a server side collection
.handler(":user/connections", this::handleGetUserConnectionsListAsync)
//connect is a controller for resource user, another user id is passed as query parameter 'to'
//e.g. POST /v1/users/<user-id>/connect?to=<another-user-id>
.handler(":user/connect", this::handleConnectionCreationAsync)
.handler(context ->
//specify handlers for HTTP methods, (i.e. GET /users -> handleGetAllUsersAsync)
context.byMethod(spec ->
spec.post(this::handleAddNewUserAsync)));
}
开发者ID:masgari,项目名称:microservices-sample,代码行数:15,代码来源:UsersCollectionHandler.java
示例5: execute
import ratpack.handling.Chain; //导入依赖的package包/类
@Override
public void execute(Chain chain) throws Exception {
//read id parameter from path
chain
//mapped to /v1/entities/:id
.handler(":id", ctx -> ctx.byMethod(spec -> spec.get(this::handleFindByIdAsync)))
//mapped to /v1/entities
.handler(ctx -> ctx.byMethod(spec -> spec.get(this::handleGetListAsync).post(this::handleSaveAsync)));
}
开发者ID:masgari,项目名称:microservices-sample,代码行数:10,代码来源:EntitiesCollectionHandler.java
示例6: getHandlers
import ratpack.handling.Chain; //导入依赖的package包/类
public List<Action<Chain>> getHandlers() {
return handlers;
}
开发者ID:beryx,项目名称:text-io,代码行数:4,代码来源:RatpackDataServer.java
示例7: execute
import ratpack.handling.Chain; //导入依赖的package包/类
@Override
public void execute(Chain chain) throws Exception {
chain.prefix(EntitiesCollectionHandler.COLLECTION_NAME, chain.getRegistry().get(EntitiesCollectionHandler.class))
//default handler, show REST endpoints
.handler(ctx -> ctx.render("Persistence Service:\nSave: POST /v1/entities\nGet by id: GET /v1/entities/:id"));
}
开发者ID:masgari,项目名称:microservices-sample,代码行数:7,代码来源:PersistenceHandlerFactory.java
示例8: fromChain
import ratpack.handling.Chain; //导入依赖的package包/类
/**
* Creates an embedded application with a default launch config (no base dir, ephemeral port) and the given handler chain.
* <p>
* If you need to tweak the launch config, use {@link #fromLaunchConfigBuilder(Function)}.
*
* @param action the handler chain definition
* @return a newly created embedded application
*/
static EmbeddedApp fromChain(Action<? super Chain> action) {
return fromLaunchConfigBuilder(lcb -> lcb.build(lc -> Handlers.chain(lc, action)));
}
开发者ID:jprante,项目名称:elasticsearch-plugin-ratpack,代码行数:12,代码来源:EmbeddedApp.java
注:本文中的ratpack.handling.Chain类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论