removed HTML template from REST controller

This commit is contained in:
marius 2020-04-18 21:35:05 +02:00
parent 5c033cbbdc
commit f29ebcd74c
2 changed files with 26 additions and 5 deletions

View File

@ -15,17 +15,14 @@ class JokeController {
@Autowired
lateinit var jokeService: JokeService
@RequestMapping(value=["/", ""], method = [RequestMethod.GET])
fun showJoke(model : Model) : String {
model.addAttribute("joke", jokeService.joke)
return "chucknorris"
}
@GetMapping(value=["/joke", ""], produces = [MediaType.APPLICATION_JSON_VALUE])
fun showJokeJSON(model : Model) : String {
model.addAttribute("joke", jokeService.jokeJSON)
return "chucknorris"
}
}

View File

@ -0,0 +1,24 @@
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
}
}