Skip to content
Permalink
Browse files

Step 3: Add JSON handling

  • Loading branch information...
baens committed Feb 17, 2018
1 parent c281332 commit 173f0916dbea62ca4f5ed982bf7bdaf062af58fb
Showing with 14 additions and 2 deletions.
  1. +5 −2 build.gradle
  2. +9 −0 src/jaxrs/resources/HelloWorld.kt
@@ -19,10 +19,13 @@ repositories {
mavenCentral()
}

def jerseyVersion = "2.26"

dependencies {
compile 'org.jetbrains.kotlin:kotlin-stdlib-jre8'
compile "org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.26"
compile "org.glassfish.jersey.inject:jersey-hk2:2.26"
compile "org.glassfish.jersey.containers:jersey-container-grizzly2-http:${jerseyVersion}"
compile "org.glassfish.jersey.inject:jersey-hk2:${jerseyVersion}"
compile "org.glassfish.jersey.media:jersey-media-json-jackson:${jerseyVersion}"
}

/**
@@ -2,9 +2,18 @@ package jaxrs.resources

import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType

@Path("helloWorld")
class HelloWorldResource{
@GET
fun helloWorld() = "Hello World"

data class HelloJson(val prop1: Int, val prop2: String)

@GET
@Path("json")
@Produces(MediaType.APPLICATION_JSON)
fun helloJson() = HelloJson(1, "test")
}

0 comments on commit 173f091

Please sign in to comment.
You can’t perform that action at this time.