Kweku
09/20/2021, 2:10 PMFunction doesn't have or inherit @Throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError. It is considered unexpected and unhandled instead. Program will be terminated.
Hien Nguyen
09/21/2021, 7:58 AMio.ktor.util.date.GMTDate
how to get timestamp of next month with GMTDate 😞 ?tylerwilson
09/21/2021, 4:02 PMparameters.apply {
append("key", value)
...
}
but all the append calls have the
This API is internal in ktor and should not be used. It could be removed or changed without notice.warning. Is there is a more standard way to define params that will not give this warning?
phil
09/21/2021, 6:27 PMHttpClient
to send a POST
request to a host in a KMM project. When running the project from an Android app, if I manually set up the Android device on a network by selecting it in the Android system settings, I’m able to connect to the host and send the request using ktor successfully. However if I connect the Android device to the network programmatically via Android’s requestNetwork API, my request with ktor fails immediately with the error java.net.ConnectException: Failed to connect to /<host_ip_address>:80
. Has anyone ever encountered this before, or have any idea as to what might be going on?jeggy
09/22/2021, 1:22 PMDazai
09/22/2021, 4:45 PMDazai
09/22/2021, 4:47 PMBart
09/22/2021, 9:45 PMcall.receive
Example json:
{Key:[{Var:value, var:value},{Var:value, var:value}]}
Any idea how i can handle more that one in single route? Also did its possible to combine two keys in one route?johnaqel
09/23/2021, 6:40 AMrouting {
get("/orders") {
v1 being the base path.Ivan Brko
09/23/2021, 5:52 PMŁukasz Bednarczyk
09/24/2021, 6:51 AMLost Illusion
09/24/2021, 10:59 PMSendChannel
provided or whether I should be using openWriteChannel
and sending my data through the returned ByteWriteChannel
instead.Jan
09/25/2021, 9:22 PMŁukasz Bednarczyk
09/26/2021, 7:14 AMWill Bartlett
09/27/2021, 12:46 PMIsaacMart
09/29/2021, 3:28 AMfun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
@KtorExperimentalAPI
@KtorExperimentalLocationsAPI
@Suppress("unused") // Referenced in application.conf
fun Application.module() {
install(Locations) {
}
install(Sessions) {
cookie<MySession>("MY_SESSION") {
cookie.extensions["SameSite"] = "lax"
}
}
DatabaseFactory.init()
val userRepository = UserRepositoryImp()
val taskerRepository = TaskerRepositoryImp()
val requestRepository = RequestRepositoryImp()
val messageRepository = MessageRepositoryImp()
val reviewRepository = ReviewRepositoryImp()
val jwtService = JwtService()
val hashFunction = { s: String -> hash(s) }
install(Authentication) {
jwt("jwt") {
verifier(jwtService.verifier)
realm = "Tasksfy"
validate {
val payload = it.payload
val claim = payload.getClaim("id")
val claimString = claim.asInt()
val user = userRepository.getUser(claimString)
user
}
}
}
}
My userRoute class for login.Where am storing the session id
@KtorExperimentalLocationsAPI
fun Route.users(db: UserRepository, jwtService: JwtService, hashFunction: (String) -> String) {
post<UserLoginRoute> {
val signInParameters = call.receive<Parameters>()
val password =
signInParameters["password"] ?: return@post call.respond(HttpStatusCode.Unauthorized, "Missing Fields")
val phoneNumber = signInParameters["phone_number"] ?: return@post call.respond(
HttpStatusCode.Unauthorized,
"Missing Fields"
)
val hash = hashFunction(password)
try {
val currentUser = db.getUserByPhone(phoneNumber)
currentUser?.user_id?.let {
if (currentUser.password == hash) {
call.sessions.set(MySession(it)) //Storing the user id here
val token = jwtService.generateToken(currentUser)
// call.respondText(jwtService.generateToken(currentUser))
call.respond(
ResponseDefault(
BaseResponse(true, "Welcome back " + currentUser.first_name, token),
currentUser
)
)
} else {
call.respond(BaseResponse(false, "Invalid Login details!", ""))
}
}
} catch (e: Throwable) {
application.log.error("Failed to register user", e)
call.respond(BaseResponse(false, "Problem retrieving User.Try again later! " + e.message,""))
}
}
My Session Class
data class MySession(val userId : Int) {
}
Here is my depedencies incase there could be problemTiago Nunes
09/30/2021, 9:54 AMTiago Nunes
09/30/2021, 2:35 PMHamza Ahmad
10/01/2021, 6:08 AMŁukasz Kłosiński
10/01/2021, 9:16 AMJohn O'Reilly
10/01/2021, 10:10 AMJose A.
10/01/2021, 1:15 PMcall.respondBytesWriter {
jobOutputRepository.get(id, subId).collect { writeFully("$it\n".toByteArray()) }
}
But with curl I'm getting curl: (18) transfer closed with outstanding read data remaining
I tried to add a flush()
but I got the same error. Any ideas?Yousef
10/02/2021, 5:08 PMViktor Petrovski
10/04/2021, 12:33 PMcron jobs?
I want to implement a repetitive task that will execute each ~hour or so to analyse the data created in that hour. Thanks in advance 🙏Sourabh Rawat
10/04/2021, 1:57 PM<https://foo.com/{id}/car/{bar}>
?
I need to set the values of id
and bar
Thanks in advance.Jonathan Hollingsworth
10/04/2021, 7:14 PMMiquel Àngel Román
10/05/2021, 8:33 AMJim
10/05/2021, 7:11 PMBerkay
10/06/2021, 10:56 AMMark Schisler
10/06/2021, 10:27 PMMark Schisler
10/06/2021, 10:27 PMRustam Siniukov
10/08/2021, 12:03 PMe5l
10/08/2021, 12:05 PMcoroutineContext
field in the configuration of the test environment in the new testing designGrégory Lureau
03/14/2022, 2:49 PMMark Schisler
03/22/2022, 6:55 PM