Skip to content

Commit

Permalink
#23 Initial port to Javalin6
Browse files Browse the repository at this point in the history
  • Loading branch information
mvysny committed Feb 28, 2024
1 parent c987b6c commit beb541e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ vaadin-core = { module = "com.vaadin:vaadin-core", version.ref = "vaadin" }
junit-jupiter-engine = "org.junit.jupiter:junit-jupiter-engine:5.10.2"
junit-platform-launcher = "org.junit.platform:junit-platform-launcher:1.10.2"
kaributesting = "com.github.mvysny.kaributesting:karibu-testing-v24:2.1.4"
javalin = "io.javalin:javalin:5.6.1"
javalin = "io.javalin:javalin:6.1.2"
commons-io = "commons-io:commons-io:2.15.0"

[plugins]
Expand Down
11 changes: 7 additions & 4 deletions testapp-kotlin/src/main/kotlin/com/example/MyJavalinServlet.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package com.example

import io.javalin.Javalin
import io.javalin.apibuilder.ApiBuilder.get
import io.javalin.http.Context
import io.javalin.http.servlet.JavalinServlet
import jakarta.servlet.Servlet
import jakarta.servlet.annotation.WebServlet
import jakarta.servlet.http.HttpServlet
import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse

@WebServlet(name = "MyJavalinServlet", urlPatterns = ["/rest/*"])
class MyJavalinServlet : HttpServlet() {
private val javalin: JavalinServlet = Javalin.createStandalone()
.get("/rest") { ctx: Context -> ctx.result("Hello!") }
.javalinServlet()
private val javalin: Servlet = Javalin.create {
it.router.apiBuilder {
get("/rest") { ctx: Context -> ctx.result("Hello!") }
}
} .javalinServlet()

override fun service(req: HttpServletRequest, resp: HttpServletResponse) {
javalin.service(req, resp)
Expand Down

0 comments on commit beb541e

Please sign in to comment.