fixing docker build
This commit is contained in:
@@ -2,21 +2,30 @@ package com.becausesec.chuckjokes.controllers
|
||||
|
||||
import com.becausesec.chuckjokes.services.JokeService
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.stereotype.Controller
|
||||
import org.springframework.ui.Model
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RequestMethod
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.stereotype.Controller
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
|
||||
|
||||
@Controller
|
||||
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"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.becausesec.chuckjokes.services
|
||||
|
||||
|
||||
import guru.springframework.norris.chuck.ChuckNorrisQuotes
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.stereotype.Service
|
||||
import com.google.gson.*
|
||||
|
||||
@Service
|
||||
interface JokeService {
|
||||
val joke:String
|
||||
val jokeJSON:String
|
||||
}
|
||||
|
||||
@Component
|
||||
@@ -16,4 +19,9 @@ class JokeServiceImpl:JokeService {
|
||||
|
||||
override val joke: String
|
||||
get() = chuckNorrisQuotes.randomQuote
|
||||
|
||||
|
||||
override val jokeJSON : String
|
||||
get() = JsonParser().parse("{ \"joke #1\" : \"" + chuckNorrisQuotes.randomQuote + "\" }").toString()
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user