• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TkForward类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.takes.facets.forward.TkForward的典型用法代码示例。如果您正苦于以下问题:Java TkForward类的具体用法?Java TkForward怎么用?Java TkForward使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TkForward类属于org.takes.facets.forward包,在下文中一共展示了TkForward类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: requestAuthentication

import org.takes.facets.forward.TkForward; //导入依赖的package包/类
/**
 * PsBasic can request authentication.
 * @throws Exception If some problem inside
 */
@Test
public void requestAuthentication() throws Exception {
    final Take take = new TkForward(
        new TkAuth(
            new TkSecure(
                new TkText("secured area...")
            ),
            new PsBasic(
                "the realm 5",
                new PsBasic.Default("bob pwd88 urn:users:bob")
            )
        )
    );
    MatcherAssert.assertThat(
        new RsPrint(
            take.act(new RqFake())
        ).print(),
        Matchers.containsString("HTTP/1.1 401 Unauthorized\r\n")
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:25,代码来源:PsBasicTest.java


示例2: addsNewDomain

import org.takes.facets.forward.TkForward; //导入依赖的package包/类
/**
 * TkCommand can add new domain.
 * @throws Exception If something goes wrong.
 */
@Test
public void addsNewDomain() throws Exception {
    final String name = "foo";
    final String urn = "urn:test:19";
    final Request req = new RqWithAuth(
        urn,
        new RqFake(
            "GET",
            String.format(
                "/d/%s?command=domain+add+test.thindeck.com", name
            )
        )
    );
    final Base base = new FkBase();
    final Decks decks = base.user(urn).decks();
    decks.add(name);
    new FkDeck("", new TkForward(new TkCommand(base))).route(req).get();
    MatcherAssert.assertThat(
        new Deck.Smart(decks.get(name)).xml(),
        XhtmlMatchers.hasXPaths(
            "/deck/domains[count(domain)=1]",
            "/deck/domains[domain='test.thindeck.com']"
        )
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:30,代码来源:TkCommandTest.java


示例3: make

import org.takes.facets.forward.TkForward; //导入依赖的package包/类
private static Take make(Base base) {
    return new TkAppFallback(
            new TkSlf4j(
                    new TkForward(
                            new TkFork(
                                    new FkRegex("/", "try /categories"),
                                    new FkRegex("/categories", new TkFork(
                                            new FkMethods("GET", new TkCategories(base)),
                                            new FkMethods("POST,PUT", new TkCategoryAdd(base))
                                    )),
                                    new FkRegex("/categories/(?<number>[^/]+)", new TkFork(
                                            new FkMethods("GET", new TkCategory(base)),
                                            new FkMethods("POST,PUT", new TkCategoryUpdate(base)),
                                            new FkMethods("DELETE", new TkCategoryDelete(base))
                                    )),
                                    new FkRegex("/products", new TkFork(
                                            new FkMethods("GET", new TkProducts(base)),
                                            new FkMethods("POST,PUT", new TkProductAdd(base))
                                    )),
                                    new FkRegex("/products/(?<number>[^/]+)", new TkFork(
                                            new FkMethods("GET", new TkProduct(base)),
                                            new FkMethods("POST,PUT", new TkProductUpdate(base)),
                                            new FkMethods("DELETE", new TkProductDelete(base))
                                    )),
                                    new FkRegex("/categories/(?<number>[^/]+)/products", new TkFork(
                                            new FkMethods("GET", new TkCategoryProducts(base)),
                                            new FkMethods("POST,PUT", new TkCategoryProductsAdd(base))
                                    )),
                                    new FkRegex("/categories/(?<ctgId>[^/]+)/products/(?<prdId>[^/]+)", new TkFork(
                                            new FkMethods("POST,PUT", new TkCategoryProductAdd(base)),
                                            new FkMethods("DELETE", new TkCategoryProductDelete(base))
                                    ))
                            )
                    )
            )
    );
}
 
开发者ID:yaroska,项目名称:true_oop,代码行数:38,代码来源:TkApp.java


示例4: make

import org.takes.facets.forward.TkForward; //导入依赖的package包/类
/**
 * Ctor.
 * @param base Base
 * @return Takes
 * @throws IOException If fails
 */
private static Take make(final Base base) throws IOException {
    if (!"UTF-8".equals(Charset.defaultCharset().name())) {
        throw new IllegalStateException(
            String.format(
                "default encoding is %s", Charset.defaultCharset()
            )
        );
    }
    return new TkWithHeaders(
        new TkVersioned(
            new TkMeasured(
                new TkGzip(
                    new TkFlash(
                        new TkAppFallback(
                            new TkAppAuth(
                                new TkForward(
                                    TkApp.regex(base)
                                )
                            )
                        )
                    )
                )
            )
        ),
        String.format("X-Wring-Revision: %s", TkApp.REV),
        "Vary: Cookie"
    );
}
 
开发者ID:yegor256,项目名称:wring,代码行数:35,代码来源:TkApp.java


示例5: make

import org.takes.facets.forward.TkForward; //导入依赖的package包/类
/**
 * Ctor.
 * @param base Base
 * @return Take
 * @throws IOException If fails
 */
private static Take make(final Base base) throws IOException {
    if (!"UTF-8".equals(Charset.defaultCharset().name())) {
        throw new IllegalStateException(
            String.format(
                "default encoding is %s", Charset.defaultCharset()
            )
        );
    }
    return new TkWithHeaders(
        new TkVersioned(
            new TkMeasured(
                new TkFlash(
                    new TkAppFallback(
                        new TkForward(
                            new TkAppAuth(
                                TkApp.regex(base)
                            )
                        )
                    )
                )
            )
        ),
        String.format("X-Thindeck-Version: %s", TkApp.VERSION),
        "Vary: Cookie"
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:33,代码来源:TkApp.java


示例6: forwardsCorrectly

import org.takes.facets.forward.TkForward; //导入依赖的package包/类
/**
 * TkCommand can forward to the right URL.
 * @throws Exception If something goes wrong.
 */
@Test
public void forwardsCorrectly() throws Exception {
    final String name = "orchard";
    final String urn = "urn:test:554";
    final Request req = new RqWithAuth(
        urn,
        new RqFake(
            "X",
            String.format(
                "/d/%s?command=domain+remove+x.com", name
            )
        )
    );
    final Base base = new FkBase();
    final Decks decks = base.user(urn).decks();
    decks.add(name);
    MatcherAssert.assertThat(
        new RsPrint(
            new TkForward(
                new TkFork(
                    new FkDeck("", new TkCommand(base))
                )
            ).act(req)
        ).printHead(),
        Matchers.containsString(
            String.format("Location: http://www.example.com/d/%s", name)
        )
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:34,代码来源:TkCommandTest.java


示例7: addsNewRepo

import org.takes.facets.forward.TkForward; //导入依赖的package包/类
/**
 * TkCommand can add new repo.
 * @throws Exception If something goes wrong.
 */
@Test
public void addsNewRepo() throws Exception {
    final String name = "lion";
    final String urn = "urn:test:443";
    final Request req = new RqWithAuth(
        urn,
        new RqFake(
            "PUT",
            String.format(
                "/d/%s?command=repo+put+https://github.com/yegor256/x.git",
                name
            )
        )
    );
    final Base base = new FkBase();
    final Decks decks = base.user(urn).decks();
    decks.add(name);
    new FkDeck("", new TkForward(new TkCommand(base))).route(req).get();
    MatcherAssert.assertThat(
        new Deck.Smart(decks.get(name)).xml(),
        XhtmlMatchers.hasXPaths(
            "/deck/repo",
            "/deck/repo/uri"
        )
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:31,代码来源:TkCommandTest.java


示例8: wastesSelectedContainer

import org.takes.facets.forward.TkForward; //导入依赖的package包/类
/**
 * TkCommand can waste a container.
 * @throws Exception If something goes wrong.
 */
@Test
public void wastesSelectedContainer() throws Exception {
    final String name = "tiger";
    final String urn = "urn:test:909";
    final Request req = new RqWithAuth(
        urn,
        new RqFake(
            "POST",
            String.format("/d/%s?command=container+waste+a1b2c3e4", name)
        )
    );
    final Base base = new FkBase();
    final Decks decks = base.user(urn).decks();
    decks.add(name);
    new Deck.Smart(decks.get(name)).update(
        Joiner.on(' ').join(
            "<deck><containers><container",
            " type='blue' state='alive'><name>a1b2c3e4</name>",
            "<host>127.0.0.1</host><image>foo/foo-aaaabbbb</image>",
            "</container></containers></deck>"
        )
    );
    new FkDeck("", new TkForward(new TkCommand(base))).route(req).get();
    MatcherAssert.assertThat(
        new Deck.Smart(decks.get(name)).xml(),
        XhtmlMatchers.hasXPaths(
            "/deck/containers/container[name='a1b2c3e4' and @waste]"
        )
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:35,代码来源:TkCommandTest.java


示例9: wastesSelectedImage

import org.takes.facets.forward.TkForward; //导入依赖的package包/类
/**
 * TkCommand can waste an image.
 * @throws Exception If something goes wrong.
 */
@Test
public void wastesSelectedImage() throws Exception {
    final String name = "panda";
    final String urn = "urn:test:4333";
    final Request req = new RqWithAuth(
        urn,
        new RqFake(
            "INFO",
            String.format(
                "/d/%s?command=image+waste+test/test-a1b2c3e4", name
            )
        )
    );
    final Base base = new FkBase();
    final Decks decks = base.user(urn).decks();
    decks.add(name);
    new Deck.Smart(decks.get(name)).update(
        Joiner.on(' ').join(
            "<deck><images><image",
            " type='blue'><name>test/test-a1b2c3e4</name>",
            "<repo>abcd0099</repo><uri>#</uri>",
            "</image></images></deck>"
        )
    );
    new FkDeck("", new TkForward(new TkCommand(base))).route(req).get();
    MatcherAssert.assertThat(
        new Deck.Smart(decks.get(name)).xml(),
        XhtmlMatchers.hasXPaths(
            "/deck/images/image[name='test/test-a1b2c3e4' and @waste]"
        )
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:37,代码来源:TkCommandTest.java


示例10: app

import org.takes.facets.forward.TkForward; //导入依赖的package包/类
/**
 * Ctor.
 * @param base Base
 * @return App
 * @throws IOException If fails
 */
private static Take app(final Base base) throws IOException {
    return new TkWithHeaders(
        new TkVersioned(
            new TkMeasured(
                new TkFlash(
                    TkApp.auth(
                        TkApp.safe(
                            new TkForward(
                                new TkGzip(
                                    new TkFork(
                                        new FkRegex("/robots.txt", ""),
                                        new FkRegex(
                                            "/org/takes/.+\\.xsl",
                                            new TkClasspath()
                                        ),
                                        new FkRegex(
                                            "/xsl/[a-z\\-]+\\.xsl",
                                            new TkWithType(
                                                TkApp.refresh("./src/main/xsl"),
                                                "text/xsl"
                                            )
                                        ),
                                        new FkRegex(
                                            "/css/[a-z]+\\.css",
                                            new TkWithType(
                                                TkApp.refresh("./src/main/scss"),
                                                "text/css"
                                            )
                                        ),
                                        new FkRegex(
                                            "/images/[a-z]+\\.svg",
                                            new TkWithType(
                                                TkApp.refresh("./src/main/resources"),
                                                "image/svg+xml"
                                            )
                                        ),
                                        new FkRegex(
                                            "/images/[a-z]+\\.png",
                                            new TkWithType(
                                                TkApp.refresh("./src/main/resources"),
                                                "image/png"
                                            )
                                        ),
                                        new FkRegex("/", new TkIndex()),
                                        new FkRegex("/scripts", new TkScripts(base)),
                                        new FkRegex("/script", new TkScript(base)),
                                        new FkRegex("/save", new TkSave(base)),
                                        new FkRegex("/delete", new TkDelete(base)),
                                        new FkRegex("/flush", new TkFlush(base)),
                                        new FkRegex("/pay", new TkPay(base)),
                                        new FkRegex("/delete-log", new TkDeleteLog(base)),
                                        new FkRegex("/logs", new TkLogs(base)),
                                        new FkRegex("/log", new TkLog()),
                                        new FkRegex("/log-link", new TkLogLink(base))
                                    )
                                )
                            )
                        )
                    )
                )
            )
        ),
        new Sprintf("X-ThreeCopies-Revision: %s", TkApp.REV).toString(),
        "Vary: Cookie"
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:73,代码来源:TkApp.java


示例11: make

import org.takes.facets.forward.TkForward; //导入依赖的package包/类
/**
 * Ctor.
 * @param home Home directory
 * @return The take
 * @throws IOException If fails
 */
private static Take make(final Path home) throws IOException {
    final Futures futures = new Futures(new Reports(home));
    return new TkFallback(
        new TkForward(
            new TkFork(
                new FkRegex("/", new TkIndex()),
                new FkRegex("/robots.txt", new TkText("")),
                new FkRegex("/mistakes", new TkMistakes()),
                new FkRegex(
                    "/flush",
                    (Take) req -> new RsText(
                        String.format("%d flushed", new Results().flush())
                    )
                ),
                new FkRegex("/all", new TkAll()),
                new FkRegex("/queue", new TkQueue(futures)),
                new FkRegex(
                    ".+\\.xsl",
                    new TkWithType(
                        new TkClasspath(),
                        "text/xsl"
                    )
                ),
                new FkRegex(
                    "/jpeek\\.css",
                    new TkWithType(
                        new TkText(
                            new TextOf(
                                new ResourceOf("org/jpeek/jpeek.css")
                            ).asString()
                        ),
                        "text/css"
                    )
                ),
                new FkRegex(
                    "/([^/]+)/([^/]+)(.*)",
                    new TkReport(
                        new AsyncReports(
                            // @checkstyle MagicNumber (1 line)
                            new SolidBiFunc<>(futures, 100)
                        )
                    )
                )
            )
        ),
        new FbChain(
            new FbStatus(
                HttpURLConnection.HTTP_NOT_FOUND,
                (Fallback) req -> new Opt.Single<>(
                    new RsWithStatus(
                        new RsText(req.throwable().getMessage()),
                        req.code()
                    )
                )
            ),
            req -> {
                Sentry.capture(req.throwable());
                return new Opt.Single<>(
                    new RsWithStatus(
                        new RsText(
                            new TextOf(req.throwable()).asString()
                        ),
                        HttpURLConnection.HTTP_INTERNAL_ERROR
                    )
                );
            }
        )
    );
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:76,代码来源:TkApp.java



注:本文中的org.takes.facets.forward.TkForward类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ApplicationConfigurationType类代码示例发布时间:2022-05-23
下一篇:
Java BasicLineIterator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap