Skip to content

Commit 0ff3ff9

Browse files
authored
Update to Hexagon 1.4.0 (#6760)
* Fix error with URLs in JEE servers * Clean up * Avoid classpath URLs * Fix template loading error * Fix template loading error * Chores * Fix template loading error
1 parent 2d47052 commit 0ff3ff9

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

frameworks/Kotlin/hexagon/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ plugins {
44
}
55

66
ext {
7-
gradleScripts = "https://raw.githubusercontent.com/hexagonkt/hexagon/1.3.20/gradle"
7+
gradleScripts = "https://raw.githubusercontent.com/hexagonkt/hexagon/1.4.0/gradle"
88

9-
hexagonVersion = "1.3.20"
10-
hikariVersion = "4.0.3" // TODO Check with 3.4.5, 4.0.3 or 5.0.0
9+
hexagonVersion = "1.4.0"
10+
hikariVersion = "5.0.0"
1111
jettyVersion = "10.0.6"
1212
postgresqlVersion = "42.2.23"
13-
cache2kVersion = "2.0.0.Final"
13+
cache2kVersion = "2.2.1.Final"
1414
jacksonBlackbirdVersion = "2.12.4"
1515
}
1616

frameworks/Kotlin/hexagon/hexagon-resin-mongodb.dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ WORKDIR /resin
2121
RUN curl -sL $RESIN | tar xz --strip-components=1
2222
RUN rm -rf webapps/*
2323
COPY --from=gradle_build /hexagon/build/libs/ROOT.war webapps/ROOT.war
24+
COPY src/main/resources/fortunes.pebble.html fortunes.pebble.html
2425
EXPOSE 9090
2526
CMD ["java", "-jar", "lib/resin.jar", "console"]

frameworks/Kotlin/hexagon/hexagon-resin-postgresql.dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ WORKDIR /resin
2121
RUN curl -sL $RESIN | tar xz --strip-components=1
2222
RUN rm -rf webapps/*
2323
COPY --from=gradle_build /hexagon/build/libs/ROOT.war webapps/ROOT.war
24+
COPY src/main/resources/fortunes.pebble.html fortunes.pebble.html
2425
EXPOSE 8080
2526
CMD ["java", "-jar", "lib/resin.jar", "console"]

frameworks/Kotlin/hexagon/src/main/kotlin/Controller.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
package com.hexagonkt
22

3+
import com.hexagonkt.helpers.require
34
import com.hexagonkt.http.server.Call
45
import com.hexagonkt.http.server.Router
56
import com.hexagonkt.serialization.Json
67
import com.hexagonkt.serialization.toFieldsMap
78
import com.hexagonkt.store.BenchmarkStore
89
import com.hexagonkt.templates.TemplatePort
10+
import java.net.URL
911
import java.util.concurrent.ThreadLocalRandom
1012

1113
class Controller(private val settings: Settings) {
1214

15+
private val templates: Map<String, URL> = mapOf(
16+
"pebble" to (urlOrNull("classpath:fortunes.pebble.html") ?: URL("file:/resin/fortunes.pebble.html"))
17+
)
18+
1319
internal val router: Router by lazy {
1420
Router {
1521
before {
@@ -42,7 +48,7 @@ class Controller(private val settings: Settings) {
4248
val context = mapOf("fortunes" to sortedFortunes)
4349

4450
response.contentType = "text/html;charset=utf-8"
45-
ok(templateAdapter.render("fortunes.$templateKind.html", context))
51+
ok(templateAdapter.render(templates.require(templateKind), context))
4652
}
4753

4854
private fun Call.dbQuery(store: BenchmarkStore) {
@@ -77,4 +83,12 @@ class Controller(private val settings: Settings) {
7783

7884
private fun randomWorld(): Int =
7985
ThreadLocalRandom.current().nextInt(settings.worldRows) + 1
86+
87+
private fun urlOrNull(path: String): URL? =
88+
try {
89+
URL(path)
90+
}
91+
catch (e: Exception) {
92+
null
93+
}
8094
}

frameworks/Kotlin/hexagon/src/main/kotlin/WebListenerServer.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@ import javax.servlet.annotation.WebListener
1414
SerializationManager.mapper = JacksonMapper
1515
SerializationManager.formats = linkedSetOf(Json)
1616
}
17-
18-
val webRouter = super.router
1917
}

0 commit comments

Comments
 (0)