Skip to content

Commit

Permalink
embedding level
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Apr 7, 2017
1 parent c19f66a commit 0d20da4
Showing 1 changed file with 72 additions and 82 deletions.
154 changes: 72 additions & 82 deletions src/main/java/io/jare/tk/TkApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
* @checkstyle MultipleStringLiteralsCheck (500 lines)
* @checkstyle ClassFanOutComplexityCheck (500 lines)
* @checkstyle LineLength (500 lines)
*/
@SuppressWarnings("PMD.ExcessiveImports")
public final class TkApp extends TkWrap {
Expand Down Expand Up @@ -103,7 +104,77 @@ private static Take make(final Base base) throws IOException {
new TkAppFallback(
new TkAppAuth(
new TkForward(
TkApp.regex(base)
new TkFork(
new FkHost(
"relay.jare.io",
new TkFallback(
new TkRelay(base),
req -> new Opt.Single<>(
new RsWithType(
new RsWithBody(
new RsWithStatus(req.code()),
String.format(
"Please, submit this stacktrace to GitHub and we'll try to help: https://github.com/yegor256/jare/issues\n\n%s",
ExceptionUtils.getStackTrace(
req.throwable()
)
)
),
"text/plain"
)
)
)
),
new FkRegex("/robots.txt", ""),
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(base)),
new FkRegex(
"/invalidate",
new TkInvalidate(
Manifests.read("Jare-CloudFrontKey"),
Manifests.read("Jare-CloudFrontSecret")
)
),
new FkAuthenticated(
new TkSecure(
new TkFork(
new FkRegex("/domains", new TkDomains(base)),
new FkRegex(
"/add",
new TkMethods(new TkAdd(base), "POST")
),
new FkRegex("/delete", new TkDelete(base))
)
)
)
)
)
)
)
Expand All @@ -116,87 +187,6 @@ private static Take make(final Base base) throws IOException {
);
}

/**
* Regex takes.
* @param base Base
* @return Takes
* @throws IOException If fails
*/
private static Take regex(final Base base) throws IOException {
return new TkFork(
new FkHost(
"relay.jare.io",
new TkFallback(
new TkRelay(base),
req -> new Opt.Single<>(
new RsWithType(
new RsWithBody(
new RsWithStatus(req.code()),
String.format(
// @checkstyle LineLength (1 line)
"Please, submit this stacktrace to GitHub and we'll try to help: https://github.com/yegor256/jare/issues\n\n%s",
ExceptionUtils.getStackTrace(
req.throwable()
)
)
),
"text/plain"
)
)
)
),
new FkRegex("/robots.txt", ""),
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(base)),
new FkRegex(
"/invalidate",
new TkInvalidate(
Manifests.read("Jare-CloudFrontKey"),
Manifests.read("Jare-CloudFrontSecret")
)
),
new FkAuthenticated(
new TkSecure(
new TkFork(
new FkRegex("/domains", new TkDomains(base)),
new FkRegex(
"/add",
new TkMethods(new TkAdd(base), "POST")
),
new FkRegex("/delete", new TkDelete(base))
)
)
)
);
}

/**
* Hit refresh fork.
* @param path Path of files
Expand Down

0 comments on commit 0d20da4

Please sign in to comment.