Skip to content

Instantly share code, notes, and snippets.

@itasyurt
Created June 28, 2020 23:01
Show Gist options
  • Save itasyurt/d00bbb1e74c48e91fa2ee3fdfba34373 to your computer and use it in GitHub Desktop.
Save itasyurt/d00bbb1e74c48e91fa2ee3fdfba34373 to your computer and use it in GitHub Desktop.
REST Controller
@RestController
@RequestMapping("/api")
class DummyController {
@Autowired
lateinit var applicationContext: ApplicationContext
@Autowired
lateinit var busProperties: BusProperties
@Autowired
lateinit var state:State
@RequestMapping("", method = [RequestMethod.GET])
fun getResult(): Int {
return state.data
}
@RequestMapping("", method = [RequestMethod.PUT])
fun updateData(@RequestParam newData: Int) {
val id = busProperties.id
val event = UpdateDataEvent(this, id, newData)
applicationContext.publishEvent(event)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment