Arnab
11/11/2021, 1:09 PMFoo
that has Bar
and Baz
as subclasses, and I make a post request that can either create a Bar
or a Baz
, how can I do that? Do I say <http://myClient.post|myClient.post><Foo> { … }
and then process the entity as either Bar
or Baz
?Aleksei Tirman [JB]
11/11/2021, 2:14 PMAleksei Tirman [JB]
11/11/2021, 2:16 PMval response = client.request<HttpResponse>("<https://example.com>")
if (response.status == HttpStatusCode.OK) {
response.receive<SuccessResponse>()
} else {
response.receive<ErrorResponse>()
}
Dennis Schröder
11/18/2021, 11:32 AMDennis Schröder
11/18/2021, 11:41 AMwhen(val response = client.request<HttpResponse>("<https://example.com>")) {
is SuccessResponse -> ... do success stuff
is ErrorResponse -> ... do error stuff
}