chucknorris-kotlin-spring/src/main/kotlin/com/becausesec/chuckjokes/controllers/JokesRestController.kt

24 lines
719 B
Kotlin

package com.becausesec.chuckjokes.controllers
import com.becausesec.chuckjokes.services.JokeService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.MediaType
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.RestController
@RestController
class JokesRestController {
@Autowired
lateinit var jokeService: JokeService
@GetMapping(value=["/joke", ""], produces = [MediaType.APPLICATION_JSON_VALUE])
@ResponseBody
fun showJokeJSON(model : Model) : String {
return jokeService.jokeJSON
}
}