January 2018
Intermediate to advanced
414 pages
10h 29m
English
For example, let's create a simple class named SimpleObject, with this structure:
package com.microservices.chapter3class SimpleObject { public val name = "hello" private val place = "world"}
Now, let's create a new controller for testing this, we will name it JsonExamplesController; it will be a RestController that has one GetMapping:
package com.microservices.chapter3import org.springframework.web.bind.annotation.GetMappingimport org.springframework.web.bind.annotation.RestController@RestControllerclass JsonExamplesController { @GetMapping(value = "/json") fun getJson() = SimpleObject()}
Then, if we execute our microservice and do a request to this URL http://localhost:8080/json, we should get:
{"name":"hello"}
We can ...
Read now
Unlock full access