otakusenpai
03/11/2019, 6:29 PMribesg
03/12/2019, 1:26 PMCaused by: kotlin.NotImplementedError: An operation is not implemented: Obtaining serializer from KClass is not available on native due to the lack of reflection. Use .serializer() directly on serializable class.
Ok, but how are you supposed to do that? Is it a bug in ktor?ribesg
03/12/2019, 3:02 PMkotlin.TypeCastException
when I create an HttpClient
using this on iOS object HttpCliiFactory {
fun create(
config: HttpClientConfig<*>.() -> Unit = {},
serializer: KotlinxSerializer.() -> Unit = {}
) =
HttpClient {
expectSuccess = false
install(MyLoggingFeature)
install(ExpectSuccess)
install(JsonFeature) {
this.serializer = KotlinxSerializer(Json.nonstrict).apply(serializer)
}
config()
}
}
ShreemanArjun
03/13/2019, 2:35 AMNikolai
03/13/2019, 7:21 AMVladimir Petrakovich
03/13/2019, 1:05 PMroute("/{id}") {
get { println(call.parameters["id"]) }
}
Given a request GET /foo?id=bar
the printed value will be "bar", not "foo".
It looks like this is intended behavior (see https://github.com/ktorio/ktor/blob/d4e1a7caaa031fb466beb1cc102192cc88623bfe/ktor-server/ktor-server-core/jvm/src/io/ktor/routing/RoutingApplicationCall.kt#L25), but why?Vinicius Carvalho
03/13/2019, 2:50 PMavolkmann
03/13/2019, 3:17 PM127.0.0.1:3500
works find with curl, but not from ktorcy
03/13/2019, 3:57 PMstanislav
03/13/2019, 5:19 PMIntroduced multiplatform websockets: jvm, js.Not yet available for iOS?
Vinicius Carvalho
03/13/2019, 8:07 PMfor(i in 0..invocations){
launch {
val response = client.call(host).response
val result = mapper.readValue<FunctionResponse>(response.readBytes())
val requestTime = response.responseTime.timestamp - response.requestTime.timestamp
channel.send(ExecutionEvent(requestTime = requestTime, pause = result.pause))
}
}
walla
03/14/2019, 7:15 AMdavidasync
03/14/2019, 9:19 AMJonas Bark
03/14/2019, 12:27 PMobobo
03/14/2019, 2:25 PMJsonFeature
and make calls like httpClient.get<DataClass>("url")
is the underlying httpResponse automatically closed, or does it expect me to close httpClient after each call? I haven't been able to find where the response is closed.Nikolai
03/14/2019, 3:35 PMfcosta
03/14/2019, 4:46 PMgalex
03/15/2019, 7:02 AMkotlin.NotImplementedError: An operation is not implemented: Obtaining serializer from KClass is not available on native due to the lack of reflection. Use .serializer() directly on serializable class.
After adding the .serializer()
to Json.stringify
I get the following error and I am not sure how to specify the serializer() for the receiving/parsing part:
io.ktor.client.call.ReceivePipelineException: Fail to run receive pipeline
Here’s my request:
val result: ActionResponse = <http://networkHttpClient.post|networkHttpClient.post> {
url(address)
body = TextContent(Json.stringify(Event.serializer(), event), contentType = ContentType.Application.Json)
}
Riccardo Montagnin
03/18/2019, 6:40 AMavolkmann
03/18/2019, 9:26 AM2019-03-18 10:25:09,867 [nettyCallPool-4-3] INFO ktor.application - 401 Unauthorized: POST - /match
2019-03-18 10:25:10,128 [nettyCallPool-4-4] INFO ktor.application - 200 OK: POST - /match
On call, the server first logs 401, then 200Nikolai
03/18/2019, 12:50 PMRiccardo Montagnin
03/19/2019, 9:32 AMpublishToMavenLocal
task I get the following error:
* Where:
Script 'D:\Coding\Borsellino\gradle\publish.gradle' line: 45
* What went wrong:
Could not evaluate onlyIf predicate for task ':borsellino-eth:publishKotlinMultiplatformPublicationToMavenLocal'.
> Cannot get property 'isLinuxHost' on extra properties extension as it does not exist
I've made sure that I applied the publish.gradle
file properly inside my project build.gradle
file as follows:
if (!rootProject.ext.skipPublish.contains(project.name)) {
apply from: rootProject.file('gradle/publish.gradle')
}
Where should I look to check I got everything properly set up?obobo
03/19/2019, 2:19 PMstanislav
03/19/2019, 2:46 PMobobo
03/19/2019, 4:43 PMContentNegotiation
, and trying to use receiveOrNull
to 'safely' get a POST body, and it feels much less useful/safe than I'd expect it to be. If I send an empty body or try to instance a data object with non-nullable fields receiveOrNull
will throw an exception. Is this by design?tjb
03/20/2019, 12:08 AMkt-server-core
but am not 100% sure how to test my changes...is there a way to bundle this so i can test?einar
03/20/2019, 8:42 PMsealed class
for this but I’m falling short when it comes to supporting the de-serialization of the response.
So something like
sealed class ApiResponse
<http://client.post|client.post><ApiResponse> { }
@Serializable data class ErrorResponse(...) : ApiResponse()
@Serializable data class SuccessResponse(..) : ApiResponse()
napperley
03/21/2019, 4:23 AMimport io.kotlintest.specs.FunSpec
import io.ktor.application.Application
import io.ktor.http.HttpMethod
import io.ktor.http.HttpStatusCode
import io.ktor.server.testing.handleRequest
import io.ktor.server.testing.withTestApplication
import kotlin.test.assertEquals
class RouteTest : FunSpec() {
init {
testHomeRouteExists()
}
private fun testHomeRouteExists() = test("homeRouteExists") {
withTestApplication(Application::main) {
with(handleRequest(HttpMethod.Get, "/")) {
assertEquals(expected = HttpStatusCode.OK, actual = response.status())
assertEquals(expected = "Battery Info Server\n", actual = response.content)
}
}
}
}
JoakimForslund
03/21/2019, 8:26 AMGary
03/22/2019, 2:51 AM@RequestHeader(value = "X-API-Key", required = true)
Gary
03/22/2019, 2:51 AM@RequestHeader(value = "X-API-Key", required = true)
spand
03/22/2019, 7:22 AMheader
function in the routing setupdave08
03/24/2019, 5:27 AMGary
03/25/2019, 12:08 AMfun Route.requireHeaders(vararg headerNames: String, build: Route.() -> Unit): Route {
val selector = HttpHeaderExistRouteSelector(headerNames)
return createChild(selector).apply(build)
}
And then using it in the routes
route("endpoint") {
requireHeaders("REQUIRED_HEADER", "REQUIRED_HEADER_2") {
get("available") {
...
}
}
}
dave08
03/25/2019, 11:10 AM