https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
server
  • a

    Alper Tekin

    12/26/2022, 1:50 PM
    Hi everyone 🙋‍♂️ I have Ktor microservices and consuming the APIs in KMM. Which one do you prefer? 1- Microservices communication to each other through HttpClients and return the response to KMM • (What about authentication between services? Shouldn’t it be with the user token? It’s also painful to transfer the token) • BTW I use consul for the service discovery and services are running in the same instance for now :) 2- Make async calls directly to each APIs and return the response to the clients in KMM Any suggestions? Thanks in advance!
    f
    • 2
    • 2
  • a

    Alexander Girke

    12/26/2022, 3:53 PM
    Hi 👋 is anyone aware of any libraries for ktor that handle REST-related concerns like generating documentation/specs, versioning of APIs, HATEOAS-support, ...? I know there are such projects for e.g. Spring, but haven't found anything for ktor.
    m
    s
    • 3
    • 7
  • f

    Fred Bowker

    12/27/2022, 4:22 PM
    Anyone know if there is a way to run the kotlin code formatter that Intellij uses from the command line
    j
    • 2
    • 2
  • f

    Fred Bowker

    12/27/2022, 4:24 PM
    it would be nice to be able to format the projects code from gradle or as a git hook when checking in, just wondering if anyone is doing this, I know you can use ktlint but looking for something that would use the same format as the intellij formatter, merry Christmas everyone 🎅
    c
    n
    • 3
    • 4
  • k

    Keval Kanpariya

    12/30/2022, 4:55 AM
    I want to filter out the courses on the basis of match query to the courseTitle. So How can I perform this operation via KMONGO at server side ? This is my Course Data Class And I have a course document in MongoDB compass. @Serializable data class Course( @BsonId var id: String = ObjectId().toString(), val courseTitle: String, val imageUrl: String, val description: String, val noOfStudentEnrolled: Int, val course_teacher : Teacher, var noOfLessons: Int, val noOfStudentRated: Int, val rating: Double, val tag: String? = null, val lessons: List<Lesson>, val time: String, )
  • s

    Saher Al-Sous

    12/30/2022, 7:40 AM
    hello... Merry Christmas and Happy New Year... does anyone has any experience with Spring Security? I added the dependency of spring-security into the project, logged in with the generated password, i can access all the pages using their links directly. but there is one page that I still can access but I can't use its form with
    POST
    function, i get the 403 error, why this is happening?
    r
    • 2
    • 4
  • v

    v79

    12/31/2022, 3:11 PM
    Are my serverless Kotlin options (for aws lambda, for instance), still SpringBoot or Micronaut?
    c
    d
    a
    • 4
    • 10
  • s

    Sam Gammon

    01/01/2023, 2:50 AM
    Hello :kotlin: friends, What if Node were more than just JS? To celebrate the new year, I am pleased to share a new project called Elide, a new server runtime, like Node or Deno, but polyglot, written in Kotlin and based on GraalVM. We are in alpha and very open to early feedback and contributions for anyone interested, over in #framework-elide 🥳 You can do wild things with it, like fast React SSR in Micronaut or Spring. Guest language support is starting with JS, but there are plans to integrate other languages like Python, Ruby, and Rust/Go/etc. via LLVM. Of course,
    native-image
    is supported out of the box. • 🚀 Trying it out
    curl -sSL --tlsv1.2 dl.elide.dev/cli/install.sh | bash -s -
    👆 the one liner works on Darwin (amd64/arm64), and Linux (amd64) so far.
    If you prefer NPX:
    npx @elide-dev/elide@alpha shell
    :kotlin-intensifies-purple: Building Kotlin apps with it • Elide can be used as a plain library with a regular Micronaut server, and Ktor support is on the way. There are Maven artifacts in a custom repository which is easy to use during the alpha; you can see a sample here. • :gradle: Gradle plugin You can easily install the Gradle plugin to build your frontend assets and your Kotlin/JS, and package it into your server binary. It will handle building for SSR and CSR both, so you can easily switch between browser rendering modes. Check it out here. Maven and Bazel support are planned. • 🖥️ Using the shell
    elide shell
    drops you into a shell just like Node (see attached screenshot), the difference being the
    URL
    class we're using here is implemented in Kotlin, backed by the road-tested power of Micronaut, KotlinX, Netty, and the Java standard library. It has simply been adapted for use in JavaScript, according to the WhatWG URL Spec. • :js: Use Kotlin/JS or regular Node stack Elide packages and consumes your JS/TS with built-in support for
    esbuild
    , so you can use a standard Node toolchain or the Kotlin/JS stack. • 💨 Super fast React SSR Because Elide is basically Kotlin with a super-fast JS runtime attached, it can do JS SSR without leaving the JVM. This can soon be drop-in compatible with many React apps. You can see a live sample here to confirm it is fast and server-rendered. The code for that sample is pasted below to show how simple it is to call back and forth between Kotlin and your React app:
    @Page class Index : PageWithProps<YourProps>(YourProps.serializer()) {
    
        // Serve React SSR.
        @Get("/") suspend fun indexPage(request: HttpRequest<*>) = ssr(request) {    // 1: tell the server we're going to do SSR for this request
          head {
            title { +"Hello, Elide!" }
            stylesheet("/styles/base.css")
            stylesheet("/styles/main.css")
            script("/scripts/ui.js", defer = true)   // <-- 2: serve the CSR bundle so it can hydrate the react SSR response
          }
          body {
            injectSSR(this@Index, request)    // <-- 3: execute the JS VM to produce the SSR response, and splice it into the server response
          }
        }
    
    }
    • 🐙 Contributors needed The future of software is much more polyglot than today's paradigm: developers love to fight about frameworks, but at the end of the day, we're all writing code, and eliminating barriers between languages means easier collaboration and more value for all of us. It shouldn't be a Node vs. The World or a Rust vs. The World argument; we should get to pick and pull the best code we want from anywhere and use it to build our apps, especially from a multi-platform language like Kotlin. This runtime and framework are designed for that future. *If you agree, join us and make a dent in the universe*; you'll have a chance to be impactful and shape a brave new idea from the ground up. • 🙏 Thank you We chose Kotlin because of the fantastic community. 2023 will be a massive year for Kotlin, and we think that betting the farm on it is reasonable and smart. We are super excited about what JetBrains and Kotlin have in store for us with K2, context receivers, value classes... just so much to look forward to. Cheers and happy new year, Kotlin devs, :kotlin-intensifies-purple: sam Posted in #feed
  • a

    André Martins

    01/02/2023, 12:55 PM
    Hey im building a client library for common apis using open api generator with ktor client and kotlinx-serialization, and I have some body fields that are snake-case. Although when im using this library from a java application somehow those fields (snake-case only) are not desserialized correctly because the response contains values and I get only nulls. Any ideias?
    a
    • 2
    • 1
  • a

    adryan_ip

    01/03/2023, 4:28 PM
    Anyone here from the Kotlin team has any update of this BUG: Reflection: Blockhound detects a blocking call from kotlin-reflect in Spring Boot application I think would be nice to have some feedback about this issue.
  • n

    Navkrishna

    01/04/2023, 12:15 PM
    Hi I wanted to use Kotlin for backend services. There are bunch of frameworks for server side. Most famous ones are Springboot, spring and Ktor. My server would be mostly IO bound. Also, another concern is currently my org uses REST but we might switch to GRPC later. I want something which might require minimal effort If I change the transport layer.
    r
    ł
    +6
    • 9
    • 19
  • c

    Canaan Etai

    01/06/2023, 11:20 PM
    Hey guys, anyone had this issue?
    2023-01-07 00:12:00.230 [qtp1706939736-20] WARN  o.eclipse.jetty.server.HttpChannel MDC= - handleException /reference/api/swagger.json com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Joda date/time type org.joda.time.DateTime not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-joda" to enable handling
    Http4k & Open api
    d
    j
    • 3
    • 14
  • a

    Aleksandar Ilic

    01/07/2023, 7:09 PM
    Hey everyone, I’m working on my first Ktor project and I have noticed that I can have routes handling separated in multiple files (e.g. auth, users, settings, etc) using
    routing
    , but when working with request validation I can’t separate the validations in multiple files. I’m thinking to make that every server feature is isolated module and I’m not sure how to break the validations apart per module. Any ideas how to proceed? Thanks
    • 1
    • 1
  • s

    Saher Al-Sous

    01/08/2023, 1:21 PM
    hello.... is there a dependency for
    org.springframework.security.core.context.DeferredSecurityContext
    r
    • 2
    • 7
  • t

    Tony Thomas

    01/08/2023, 4:56 PM
    Hey team. We were trying to write an automatic retry when using the ReactiveAuthenticationManager, with authentication handled via an API call. We came up with something like this to override the
    authenticate
    with. Do you people see any potential issues with it ?
    fun doAsyncAuthentication(
        url: HttpUrl,
      ): Mono<Authentication> {
        return webClient
          .post()
          .uri(url.toUri())
          .body(BodyInserters.fromFormData("token", "tokenValue"))
          .retrieve()
          .onStatus(HttpStatus::is4xxClientError) { response ->
            response
              .createException()
              .map { InvalidBearerTokenException(it) }
          }
          .onStatus(HttpStatus::is5xxServerError) { response ->
            Mono.error(ServiceException("Server error", response.rawStatusCode()))
          }
          .bodyToMono<TokenInfoResponse>()
          .retryWhen(Retry
            .backoff(3, Duration.ofSeconds(1))
            .filter { throwable -> throwable is ServiceException })
          .map {
            OurAuthenticationResponse(it.clientId, it.scopes)
          }
      }
  • s

    stevenson

    01/09/2023, 6:11 AM
    hi guys
  • s

    stevenson

    01/09/2023, 6:14 AM
    quick question is this a good place to ask about springboot cors configuration? i am trying to upgrade my corsConfig https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.7-Release-Notes https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter but application starts properly but when i call the base endpoint i get a 500 error and i dont know where to go to debug
  • v

    Venkat

    01/12/2023, 4:15 PM
    https://stackoverflow.com/q/75098802/10334333 Could someone answer me this question
  • c

    Carlos Valencia

    01/12/2023, 5:11 PM
    I am having one problem with my IDE and kotlin.
    Cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
    I am using kgraphql in ktor but I am seeing this problem. Not sure how to fix it.
    l
    • 2
    • 5
  • a

    Avi Perl

    01/16/2023, 2:29 PM
    What are some of the orms worth looking into? Looking to improve our interfacing with a postgres database on a server side jvm application. Ty!
    s
    c
    +4
    • 7
    • 10
  • b

    Bernhard

    01/17/2023, 10:13 AM
    looking at the Kotlin DSL for Spring Security filter chains, it seems that there is no way to configure a UserDetailsService for a SecurityFilterChain anymore; what's the recommended workaround? I'm using 2 filter chains that protect different routes and use different users; 1 for actuator and 1 for the API
    r
    • 2
    • 4
  • a

    Aleksey Blekot

    01/17/2023, 5:58 PM
    task
    stage
    fails with error for full-stack-app tutorial https://github.com/kotlin-hands-on/jvm-js-fullstack/blob/b4bebe15f848a028d2dac6a8faff0e0fe8473a13/build.gradle.kts#L111
    Execution failed for task ':installDist'.
    > Entry lib/shoppinglist-1.0-SNAPSHOT.jar is a duplicate but no duplicate handling strategy has been set.
    adding this in build.gradle doesn’t help
    tasks.withType<Copy> {
        duplicatesStrategy = DuplicatesStrategy.INCLUDE
    }
    Could somebody help me? 🙂
    • 1
    • 2
  • o

    Olufemi Adeojo

    01/21/2023, 5:02 AM
    Hi all, I am looking for a freelance Kotlin developer to build a GraphQL api using Quarkus. Please DM me if you're interested.
    v
    • 2
    • 2
  • t

    tavish pegram

    01/22/2023, 10:19 PM
    Does anyone else run into issues with getting Detekt / Spotless (with ktfmtt) / Intellij Ktfmt plugin/ and the intellij formatting to all agree? I’m running into a lot of thrashing at work, even after trying to make sure they are all standardized on ktfmt with google style (and copy pasting the editorconfig for google style from the ktfmt repo). I’m thinking of trying out ktlint instead. Anyone have similar experiences with ktfmt (or not have these problems at all with a different formatter?)
  • m

    Mikael Ståldal

    01/25/2023, 9:28 AM
    Is this supposed to be used on JVM, or only in JS? (The docs are a bit confusing.) https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.js/-promise/
    r
    s
    +2
    • 5
    • 7
  • a

    Andrés Romero

    01/26/2023, 12:57 AM
    Hi everyone! I'm looking to implement a long-living server stream with gRPC that clients can subscribe to. Context: there is a group of users with users and a lead user, when the lead starts and action
    performAction()
    which is a unary RPC. I want to notify the other users with information about that action. I would expect those members to be subscribed to another long-living RPC that facilitates sending that information. Do you have any examples of how can achieve that in Kotlin? I was looking into something like: https://dev.bitolog.com/grpc-long-lived-streaming/ https://sultanov.dev/blog/grpc-long-lived-streaming-using-observer-pattern/ But those implementations are written in Go and Java, and I'm struggling to find examples in Kotlin
    t
    • 2
    • 1
  • r

    rrva

    01/27/2023, 4:28 PM
    what coroutine-aware profilers are there? I know of DebugProbes but have not seen any tooling except that. Also found some coroutine support in JProfiler. I have a server-side app that has mixed execution where some of the code is run via the default dispatchers and some is executed outside of coroutines, on plain jvm threads. How would I create a flame graph? (maybe one for the thread perspective and one for the coroutine perspective?)
  • j

    JPilson Sumbo

    01/31/2023, 11:23 AM
    Guys I’im using Ktor for a Grade System where Authorisations have bin encapsulated in token/ I have endpoint that only people with specific authorisation can are allowed What’s the best practice to combine these authorisation ?
    authenticate(AuthorizeFor.ManageCourse, AuthorizeFor.ManageSubject){
         post("/enroll-student") {...}
    }
    Is this ok ?
    authenticate(AuthorizeFor.ManageCourse, AuthorizeFor.ManageSubject,AuthorizeFor.ManagePauta,AuthorizeFor.ManageBatch,AuthorizeFor.ManageAdmin)
  • s

    Sanjay Kasi

    02/02/2023, 9:42 AM
    Hello Everyone, I have a question regarding MDC and Ktor. We are currently using the
    CallLogging
    plugin to inject MDC values in the pipeline like so:
    fun Application.module() {
      install(CallLogging) {
    		mdc("clientIpAddress") { call ->
          call.request.header("X-Forwarded-For") ?: "UNDEFINED"
        }
      }
    }
    We are generating a
    userId
    within the route which needs to be added to MDC such that it is available outside the current co-routine context:
    fun Application.myRoutes() {
      routing {
        get("/testMDC") {
    	 	MDC.putClosable("userId", "${UUID.randomUUID()}") // <-- This is thread local and does not carry onto other co-routines
        }
      }
    }
    The
    clientIpAddress
    works fine and is logged throughout but
    userId
    only logs in local context. Is there any work around for this?
    s
    p
    • 3
    • 4
  • g

    Goetz Markgraf

    02/02/2023, 10:01 AM
    Hello. I have a ktor route that calls a simple business function to process data. The Route is responsible for receiving data from the body and passing it to the business function, and for formatting the returned values. Like so:
    get("/some/uri") {
      val data = call.receive<SomeType>()
      val result = doBusinessStuffWith(data)
      call.respond(result.doSomeFormatting()
    }
    And the business function is defined somewhere else:
    fun doBusinessStuffWith(data: SomeType): SomeReturnType {
    ...
    }
    Is there a way to test the controller in isolation by mocking the business function
    doBusinessStuffWith
    ? In Javascript, you can mock any function call with
    jest
    . I assume, it is not that easy in kotlin, but is there a nice way? Thank you for your ideas …
    d
    s
    d
    • 4
    • 9
Powered by Linen
Title
g

Goetz Markgraf

02/02/2023, 10:01 AM
Hello. I have a ktor route that calls a simple business function to process data. The Route is responsible for receiving data from the body and passing it to the business function, and for formatting the returned values. Like so:
get("/some/uri") {
  val data = call.receive<SomeType>()
  val result = doBusinessStuffWith(data)
  call.respond(result.doSomeFormatting()
}
And the business function is defined somewhere else:
fun doBusinessStuffWith(data: SomeType): SomeReturnType {
...
}
Is there a way to test the controller in isolation by mocking the business function
doBusinessStuffWith
? In Javascript, you can mock any function call with
jest
. I assume, it is not that easy in kotlin, but is there a nice way? Thank you for your ideas …
d

dave

02/02/2023, 10:04 AM
You can, of course use a mock. Suggest that you maybe think about structuring your app using Hexagonal Architecture to split your adapter logic from your business logic.
s

Sam

02/02/2023, 10:04 AM
You can indeed mock top level functions with something like #mockk. I don’t find mocking top level functions in Kotlin quite as clean as jest, but it’s not bad. The downside is it stops you from running tests in parallel.
d

Dominik Sandjaja

02/02/2023, 10:04 AM
I propose to move the
doBusinessStuffWith(...)
to a dedicated class. This would not only make testing simpler (you can then simply mock that class and the method call), but it would also clarify the responsibilities of the two classes: One for routing and request/response handling, one for doing logic.
g

Goetz Markgraf

02/02/2023, 10:07 AM
@Dominik Sandjaja That’s how you would do it with spring boot. What I like at ktor is that you don’t have to write classes but can work functional. The separation can come from different files that use private and public funtions but no classes. @Sam That sound interesting. I will try that, thank you. @dave Could be an interesting approach. But I always find the “stiching together” tiresome and data has to flow up- and downward longer ways.
Some thought that I had: Can you use Koin to inject a function? That could solve the problem and be still quite functional. I want to use Koin in the backend anyway, but am pretty new to that framework
d

Dominik Sandjaja

02/02/2023, 10:09 AM
We use Koin and we use a hexagonal approach, exactly to split the responsibilities: Input/Output into a system is e.g. the HTTP route, the actual business logic is in a separate class. Yes, it would be the same in Spring, but that does not necessarily mean that it's a bad thing 🙂
d

dave

02/02/2023, 10:09 AM
If you don't use a DI framework, you could inject a function into your controller. Probably doesn't work with the magic though 😂
g

Goetz Markgraf

02/02/2023, 10:10 AM
Thank you all. I will take a look.
d

dave

02/02/2023, 10:10 AM
fun myController(fn: (String) -> DomainThing)
View count: 14