-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#9504] Add Vert.x main page for test
- Loading branch information
Showing
6 changed files
with
174 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
agent-testweb/vertx-3-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ApiLinkPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.pinpoint.test.plugin; | ||
|
||
import io.vertx.ext.web.Route; | ||
import j2html.tags.specialized.ATag; | ||
import j2html.tags.specialized.HtmlTag; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
|
||
import static j2html.TagCreator.a; | ||
import static j2html.TagCreator.body; | ||
import static j2html.TagCreator.div; | ||
import static j2html.TagCreator.each; | ||
import static j2html.TagCreator.h1; | ||
import static j2html.TagCreator.head; | ||
import static j2html.TagCreator.html; | ||
import static j2html.TagCreator.title; | ||
|
||
/** | ||
* @author Woonduk Kang(emeroad) | ||
*/ | ||
public class ApiLinkPage { | ||
private final String title; | ||
|
||
public ApiLinkPage(String title) { | ||
this.title = Objects.requireNonNull(title, "title"); | ||
} | ||
|
||
public String buildRoute(List<Route> routes) { | ||
List<ATag> collect = routes.stream() | ||
.map(this::aTag) | ||
.collect(Collectors.toList()); | ||
return buildHtml(collect); | ||
} | ||
|
||
private ATag aTag(Route route) { | ||
return a() | ||
.withText(route.getPath()) | ||
.withHref(route.getPath()) | ||
.withTarget("_blank"); | ||
} | ||
|
||
public String buildHtml(List<ATag> aTags) { | ||
|
||
HtmlTag html = html( | ||
head(title(title)), | ||
body( | ||
h1(title), | ||
each(aTags, aTag -> div(aTag)) | ||
) | ||
); | ||
return html.render(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
agent-testweb/vertx-4-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ApiLinkPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.pinpoint.test.plugin; | ||
|
||
import io.vertx.ext.web.Route; | ||
import j2html.tags.specialized.ATag; | ||
import j2html.tags.specialized.HtmlTag; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
|
||
import static j2html.TagCreator.a; | ||
import static j2html.TagCreator.body; | ||
import static j2html.TagCreator.div; | ||
import static j2html.TagCreator.each; | ||
import static j2html.TagCreator.h1; | ||
import static j2html.TagCreator.head; | ||
import static j2html.TagCreator.html; | ||
import static j2html.TagCreator.title; | ||
|
||
/** | ||
* @author Woonduk Kang(emeroad) | ||
*/ | ||
public class ApiLinkPage { | ||
private final String title; | ||
|
||
public ApiLinkPage(String title) { | ||
this.title = Objects.requireNonNull(title, "title"); | ||
} | ||
|
||
public String buildRoute(List<Route> routes) { | ||
List<ATag> collect = routes.stream() | ||
.map(this::aTag) | ||
.collect(Collectors.toList()); | ||
return buildHtml(collect); | ||
} | ||
|
||
private ATag aTag(Route route) { | ||
return a() | ||
.withText(route.getPath()) | ||
.withHref(route.getPath()) | ||
.withTarget("_blank"); | ||
} | ||
|
||
public String buildHtml(List<ATag> aTags) { | ||
|
||
HtmlTag html = html( | ||
head(title(title)), | ||
body( | ||
h1(title), | ||
each(aTags, aTag -> div(aTag)) | ||
) | ||
); | ||
return html.render(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters