Creating new entities
Our next task is adding the first cat to our virtual shelter.
Following the REST principles, it should be a POST
request, where the body of the request may look something like this:
{"name": "Meatloaf", "age": 4}
We'll start by writing a new test:
@Test fun `POST creates a new cat`() { ... }
Backticks are a useful Kotlin feature that allows us to have spaces in the names of our functions. This helps us create descriptive test names.
Next, let's look at the body of our test:
withTestApplication(Application::mainModule) { val response = handleRequest(HttpMethod.Post, "/cats") { addHeader( HttpHeaders.ContentType, ContentType.Application.FormUrlEncoded.toString() ...