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

28 lines
770 B
Kotlin
Raw Normal View History

2019-01-06 14:12:58 +00:00
package com.becausesec.chuckjokes.controllers
import com.becausesec.chuckjokes.services.JokeService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
2020-04-18 18:52:35 +00:00
import org.springframework.http.MediaType
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.GetMapping
2019-01-06 14:12:58 +00:00
@Controller
class JokeController {
@Autowired
lateinit var jokeService: JokeService
@RequestMapping(value=["/", ""], method = [RequestMethod.GET])
2019-01-06 14:12:58 +00:00
fun showJoke(model : Model) : String {
model.addAttribute("joke", jokeService.joke)
return "chucknorris"
}
2020-04-18 18:52:35 +00:00
2019-01-06 14:12:58 +00:00
}