bitkid
07/31/2020, 6:36 AMhhariri
07/31/2020, 11:47 AMJorge R
08/01/2020, 2:52 PMDominik wuttke
08/01/2020, 6:31 PMMatthieu Stombellini
08/03/2020, 7:37 PMsavrov
08/03/2020, 9:58 PM@Serializable
class SomeRequestBody(
@SerialName("name_field")
val name: String?
)
In KTOR Server, I have defined EP with such a request body. The problem is, that it works, if json looks like:
{
"name": "some-name-string"
}
but does not work if im trying to do the same with
{
"name_field": "some-name-string"
}
Do you know how to fix it?
P.S. Content negotiation is enabled in application module like
install(ContentNegotiation) {
gson {
setPrettyPrinting()
}
}
Thank you in advanceNikky
08/04/2020, 2:43 PMclient.websocket(host, port, path) {
for(frame in incoming) {
// a `break` somewhere in here
}
close(CloseReason(CloseReason.Codes.GOING_AWAY, "OK"))
<http://logger.info|logger.info> { "sent close" }
}
<http://logger.info|logger.info> { "websocket closed" }
i see the sent closed
log message
but after that it hangs
is there any other way to close the websocket ?
PS: seems like it works better when not using CIO engine
maybe such incompabilities should be put in the docs ?jeggy
08/04/2020, 10:48 PMcodec
08/06/2020, 3:08 AMja.son
08/06/2020, 6:38 AMHank
08/06/2020, 7:17 AMbuildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.cloud.tools:appengine-gradle-plugin:$appengine_plugin_version"
}
}
apply plugin: 'kotlin'
apply plugin: 'war'
apply plugin: 'application'
apply plugin: 'com.google.cloud.tools.appengine'
appengine.deploy.projectId = 'GCLOUD_CONFIG'
appengine.deploy.version = 'GCLOUD_CONFIG'
group 'dev.hankli'
version '1.0.0'
mainClassName = "io.ktor.server.netty.EngineMain"
sourceSets {
main.kotlin.srcDirs = main.java.srcDirs = ['src']
test.kotlin.srcDirs = test.java.srcDirs = ['test']
main.resources.srcDirs = ['resources']
test.resources.srcDirs = ['testresources']
}
webAppDirName = 'webapp'
repositories {
mavenLocal()
jcenter()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "io.ktor:ktor-server-netty:$ktor_version"
implementation "ch.qos.logback:logback-classic:$logback_version"
implementation "io.ktor:ktor-server-core:$ktor_version"
implementation "io.ktor:ktor-locations:$ktor_version"
implementation "io.ktor:ktor-server-sessions:$ktor_version"
implementation "io.ktor:ktor-auth:$ktor_version"
implementation "io.ktor:ktor-auth-jwt:$ktor_version"
implementation "io.ktor:ktor-gson:$ktor_version"
implementation 'com.google.firebase:firebase-admin:6.14.0'
implementation "com.desmondtzq.ktor:ktor-auth-firebase:1.0.1"
testImplementation "io.ktor:ktor-server-tests:$ktor_version"
implementation "org.jetbrains.exposed:exposed-core:$exposed_version"
implementation "org.jetbrains.exposed:exposed-dao:$exposed_version"
implementation "org.jetbrains.exposed:exposed-jdbc:$exposed_version"
implementation "org.jetbrains.exposed:exposed-jodatime:$exposed_version"
implementation "org.postgresql:postgresql:$postgres_version"
implementation "com.zaxxer:HikariCP:$hikaricp_version"
providedCompile "com.google.appengine:appengine:$appengine_version"
}
task run(dependsOn: appengineRun) // Could not get unknown property 'appengineRun' for root project
And I’ve tried to use the Cloud Code plugin in IntelliJ IDE to run my code and there was an error that showed “Please first confirm that there is a properly placed appengine-web.xml file”, even though I’ve set the directions.
Is anyone can help me out or give me some suggestions, really appreciate.🙏Jan Stoltman
08/06/2020, 7:19 AMley
08/06/2020, 9:40 AMDominik wuttke
08/06/2020, 8:54 PMKrystian Rybarczyk
08/07/2020, 8:58 AM1.3.2-1.4.0-rc
? I’ve updated my kotlin version and ktor version in gradle, but gradle fails to build with the below. This is strange, because I can see these in maven central (which I have declared to use in my build config):
repositories {
mavenLocal()
jcenter()
}
Could anyone give me a hand here?Eric Ampire [MOD]
08/08/2020, 1:25 PMGsonConvert
install(ContentNegotiation) {
register(ContentType.Any, GsonConverter())
}
The statement generate an exception.
post("save") {
val data = call.receive<MyClass>()
}
Gunslingor
08/09/2020, 5:35 PMhhariri
08/10/2020, 7:25 AMJohn O'Reilly
08/10/2020, 8:28 AMnative-mt
version of kotlinx coroutines (assuming that's still branch in 1.4....though I guess (hope) it might be in "official" version by then?)gps
08/10/2020, 9:26 AMGunslingor
08/10/2020, 1:15 PMGunslingor
08/10/2020, 2:00 PMtarget {
browser {
webpackTask {
outputFileName = "MyProjectName.js"
}
runTask {
dependsOn("build")
devServer = devServer?.copy(
port = 8088,
proxy = mapOf("/api" to "<http://localhost:8080>")
)
}
}
}
Gunslingor
08/11/2020, 2:15 AMHank
08/11/2020, 9:37 AMGunslingor
08/11/2020, 1:17 PMLaurence
08/11/2020, 8:23 PMcall.receiveMultipart()
and then use the input stream, but when I test using postman it just hangs and doesn't fail with an error.
In Gradle I have:
// AWS S3
implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.7')
implementation 'com.amazonaws:aws-java-sdk-s3'
For the S3 client and upload function I am using:
private val s3Client = AmazonS3Client(
BasicAWSCredentials(S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY)
).apply {
withRegion<AmazonWebServiceClient>(Regions.US_EAST_1)
setS3ClientOptions(
S3ClientOptions.builder()
.setPathStyleAccess(true).build()
)
}
fun uploadFileToS3(key: String, inputStream: InputStream, metadata: ObjectMetadata): PutObjectResult =
s3Client.putObject(BUCKET_NAME, key, inputStream, metadata)
Then the route is calling:
val multiPartData = call.receiveMultipart()
multiPartData.forEachPart { part ->
when (part) {
is PartData.FileItem -> {
val key = "profile-image/${part.originalFileName ?: "unknown-file"}"
part.streamProvider()
.use { inputStream ->
val bytes: ByteArray = IOUtils.toByteArray(inputStream)
val metadata = ObjectMetadata()
metadata.contentLength = bytes.size.toLong()
val byteArrayInputStream = ByteArrayInputStream(bytes)
AwsS3.uploadFileToS3(
key,
byteArrayInputStream,
metadata
)
}
}
else -> call.respond(HttpStatusCode.InternalServerError, JSONObject(mapOf("err" to "Error uploading file")))
}
}
call.respond(
HttpStatusCode.OK,
JSONObject(mapOf("msg" to "Image uploaded successfully"))
)
Hoping someone can spot where I'm going wrong 🙂 Thanks!rudolf.hladik
08/12/2020, 11:15 AMimplementation("io.ktor:ktor-client-core:1.3.2-1.4.0-rc")
but it was not enough, it wants engine so i’ve tried implementation("io.ktor:ktor-client-cio:1.3.2-1.4.0-rc")
but it doesn’t work 😞manlan
08/12/2020, 6:13 PM@Serializable
data class Reader(
var name : String = "",
var photoUrl : String = "",
var address : Address = Address())
Kotlinx Serialization setupJohn O'Reilly
08/13/2020, 10:35 AMMgj
08/13/2020, 12:13 PMHttpResponseValidator
which seems useful, but how do i:
1. Perform a refresh request
2. Retry the failed request
Perhaps im better off wrapping my ktor calls in a helper, and handle it there instead of trying to use HttpResponseValidator
?Mgj
08/13/2020, 12:13 PMHttpResponseValidator
which seems useful, but how do i:
1. Perform a refresh request
2. Retry the failed request
Perhaps im better off wrapping my ktor calls in a helper, and handle it there instead of trying to use HttpResponseValidator
?jorge.rego
08/13/2020, 12:39 PMMgj
08/13/2020, 12:41 PMjorge.rego
08/13/2020, 1:31 PMMgj
08/13/2020, 1:38 PMjorge.rego
08/13/2020, 3:27 PMedenman
08/13/2020, 8:12 PMsuspend fun doRequest
that i run all my requests through and then recursively call it based on response codes and auth token stuff