Ananiya
11/14/2020, 4:38 PMPOST url
Authorization: key
Content-Type: application/json
{"text": ["Hello, world.", "How are you?"], "model_id":"en-es"}
which work smoothly but after i implement it in okhttp like this below
val json = """{"text": ["Hello, world.", "How are you?"], "model_id":"en-es"}""".trimMargin()
val request = RequestBody.create(JSON,json);
val response = Request.Builder()
.url(url)
.post(request)
.addHeader("Authorization","key")
.addHeader("Content-Type","application/json")
.build()
val answer = client.newCall(response).execute().body()!!.string()
println(answer)
it start throwing error from the api, i felt i have done something wrong in okhttp authorization post, please help 😩Pavel Petkevich
11/17/2020, 1:12 PMstask
11/18/2020, 8:41 PM@Serializable
data class GroupData(
@Contextual val sessionId: String,
@Contextual val groupId: String
)
delete("/api/v1/group") {
val data = call.receive<GroupData>()
...
}
The client snippet
`return axios.delete(
${serverAddress}/api/v1/group
,
{
data: {
sessionId: context.state.sessionId,
groupId
}
},
)`Vampire
11/19/2020, 9:50 AMAnaniya
11/20/2020, 8:24 AMembeddedServer(Netty, port = "ITS PORT")
or is there any system command to find which port the app is running in ?
i also packed it as jar file if it could be easy to get the portstask
11/21/2020, 6:57 AMjava -jar server.jar
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
...
I googled, that the problem is in kotlin library, which should be packed into the jar in a specific way. Documentation here https://www.jetbrains.com/help/idea/create-your-first-kotlin-app.html?section=Gradle%20Groovy tells me, that I should add special code in build.gradle. There is my code on the picture. As you can see, "from" is grey...
And I get next error for Gradle
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'server'.
<131 internal calls>
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method jar() for arguments [build_c5anurhkrrlxlaf3i7moe4k0u$_run_closure5@7f80db22] on task set of type org.gradle.api.internal.tasks.DefaultTaskContainer.
at org.gradle.internal.metaobject.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:182)
at org.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:166)
at org.gradle.api.internal.tasks.DefaultTaskContainer_Decorated.invokeMethod(Unknown Source)
at build_c5anurhkrrlxlaf3i7moe4k0u.run(/Users/stask/projects/motionLearning/chat/kotlinServer/server/build.gradle:100)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 130 more
Could you help me, how to fix the build?Mehrdad Senobari
11/23/2020, 8:35 PMlutz
11/24/2020, 2:42 AMI'm looking for learning resources as an experienced PHP developer trying to understand the subtleties of working with the JVM. For example, PHP has essentially no concept of multithreading and asynchronous programming, while it seems pretty important to JVM development. Does anyone have suggestions?They are just starting to use kotlin on the backend and ran into some performance issues w/their impl of coroutines. Any recommendations?
marzelwidmer
11/27/2020, 5:08 AMKotlin
SpringBoot
Project a RestTemplate
as Bean DSL
have some body any hint. What I’m missing…rajesh
11/30/2020, 4:04 PMJoão Rodrigues
12/02/2020, 1:29 PMLaurence
12/03/2020, 7:51 AMbuildscript {
ext.kotlin_version = '1.4.20'
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.github.jengelman.gradle.plugins:shadow:5.0.0"
}
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.4.10'
}
apply plugin: 'com.github.johnrengelman.shadow'
tasks.build.dependsOn tasks.shadowJar
shadowJar {
mergeServiceFiles()
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
jcenter()
mavenCentral()
}
compileKotlin {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
kotlinOptions {
jvmTarget = "1.8"
}
}
configurations {
invoker
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
// Every function needs this dependency to get the Functions Framework API.
compileOnly 'com.google.cloud.functions:functions-framework-api:1.0.1'
// MongoDB & KMongo
implementation "org.mongodb:mongodb-driver-sync:4.1.1"
implementation 'org.mongodb:mongodb-driver-core:4.1.1'
implementation 'org.mongodb:bson:4.1.1'
implementation 'org.mongodb:mongo-java-driver:3.12.7'
implementation 'org.litote.kmongo:kmongo-coroutine:4.2.0'
implementation "org.slf4j:slf4j-simple:1.7.30"
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
}
Connection code:
import com.mongodb.MongoClientURI
import functions.Conf.Conf.MONGO_CLIENT_URI
import org.litote.kmongo.coroutine.coroutine
import org.litote.kmongo.reactivestreams.KMongo
object Database {
init {
System.setProperty(
"org.litote.mongo.test.mapping.service",
"org.litote.kmongo.jackson.JacksonClassMappingTypeService"
)
}
// get URI for MongoDB client (eg. Mongo Atlas)
private val uri = MongoClientURI(MONGO_CLIENT_URI)
// get client
private val mongoClient = KMongo.createClient(uri.uri)
// get database
val database = mongoClient.getDatabase(uri.database).coroutine
}
seldomcoder
12/06/2020, 8:22 AMAlex Sinclair
12/07/2020, 2:26 PMrequest->logic->db->logic->response
, we could make that ->db->
call asynchronous using coroutines, but... is there a benefit? In JS the async/await
makes sense because of the single-threading and how it nicely replaces callbacks, but... if Tomcat pauses the thread (which I assume it does, I'm certainly no expert on anything I've said here) then coroutines wouldn't have much benefit, right?
I appreciate any insights you have, including schooling me on my false assumptions and faulty reasonings 🤣André Benda
12/08/2020, 3:35 PMYev Kanivets
12/11/2020, 6:05 AMKotlin 1.4.0
. (Sample project is attached).thana
12/14/2020, 10:26 AMNicodemus Ojwee
12/16/2020, 9:15 AM@Bean
public RouterFunction<ServerResponse> htmlRouter(
@Value("classpath:/public/index.html") Resource html) {
return route(GET("/"), request
-> ok().contentType(MediaType.TEXT_HTML).syncBody(html)
);
}
Michael Ortali
12/17/2020, 10:39 PMdef decorate(fn):
def wrapper(*args, **kwargs):
print("Decorated")
return fn(*args, **kwargs)
return wrapper
@decorate
def method(prop1, prop2):
return prop1 * prop2
Qverkk
12/18/2020, 12:26 PMorg.springframework.boot from 2.4.1 to 2.3.7.RELEASE
And
springCloudVersion from 2020.0.0-RC1 to Hoxton.SR9
HankG
12/19/2020, 5:01 PMck
12/21/2020, 11:41 AMnedaluOf
12/23/2020, 8:37 AMBo Zhang
12/23/2020, 2:35 PMFunction
parameters?Zdziszkee
12/23/2020, 9:35 PMStanislav Kral
12/26/2020, 7:11 PMcall.receive<T>()
?
Currently my server returns 500 Internal Server Error
, I would like to return 400 Bad Request
in some general reusable fashion. I can't seem to find any resources regarding this topic, Thanks!Poohrang
12/28/2020, 3:14 AMtransaction {
UsedItems.update({
(UsedItems.e_mail eq receive.userEmail).and(UsedItems.id eq receive.usedItemId)}) {
it[interestCnt] = interestCnt + 1 // occurs error
}
}
interestCnt value had defined in UsedItems table as below (attached image2)
val interestCnt : Column<Int> = integer("interest_cnt").default(0)
When I tried to put just value(not increasing), It works properly (attached image3)
transaction {
UsedItems.update({
(UsedItems.e_mail eq receive.userEmail).and(UsedItems.id eq receive.usedItemId)}) {
it[interestCnt] = 1
}
}
I reffered the following code in exposed github documentation.
If you want to update column value with some expression like increment use update
function or setter:
StarWarsFilms.update({ StarWarsFilms.sequelId eq 8 }) {
with(SqlExpressionBuilder) {
it.update(StarWarsFilms.sequelId, StarWarsFilms.sequelId + 1)
// or
it[StarWarsFilms.sequelId] = StarWarsFilms.sequelId + 1
}
}
My expectation is to be worked like sample code. but not
Is there any idea to solve this problem?
Thanks in advance.teremy
12/29/2020, 2:06 PMMaciej Jelen
12/29/2020, 3:11 PMUserPasswordChangedEventData
, or make it non-data class, the code would not compileQverkk
01/03/2021, 4:09 PMwait-for
and delay untill a certain service is started, before starting a new one. Thus, anyone knows a jre 11 docker image supporting wait-for
?Qverkk
01/03/2021, 4:09 PMwait-for
and delay untill a certain service is started, before starting a new one. Thus, anyone knows a jre 11 docker image supporting wait-for
?