Ролан
05/07/2021, 5:26 PMGeert
05/14/2021, 12:09 PMAbdulazeez Olaitan Gbindinninuola
05/18/2021, 10:39 AMByron Katz
05/20/2021, 10:12 PMasavio
05/21/2021, 12:37 PMVasily Scherbakov
05/23/2021, 12:28 PMAccess to fetch at '<http://127.0.0.1:8080/api/run?userId=root&profile=test>' from origin '<http://localhost:3000>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled
As i understand, i should add origin to list of allowed origins in my backend app, i do this that way
install(CORS){
method(HttpMethod.Get)
method(<http://HttpMethod.Post|HttpMethod.Post>, )
method(HttpMethod.Delete)
anyHost()
host("localhost")
}
But this dont work.
This is headers of response from js clinet
'Origin': '<http://localhost:3000>',
'Content-Type': 'application/json',
'Accept': 'application/json',
'Access-Control-Request-Headers': 'Content-Type, Authorization'
Can anyone help me please?Darren Lambert
05/24/2021, 10:04 PM2021-05-24 17:50:38.841 [eventLoopGroupProxy-4-1] ERROR ktor.application - Unhandled: POST - /Music/Add
io.ktor.features.CannotTransformContentToTypeException: Cannot transform this request's content to Musics
What i have do wrong in my code ? 😒miling_face_with_tear: (I have do many research and soluce but he doesn't work)
post("/Add") {
val post = call.receive<Musics>()
aMusicDAO.addMusic(post)
call.respondText("OK OK",ContentType.Text.Plain)
}
@Serializable
data class Musics(
val tag:Int? =null,
@JsonInclude(value=JsonInclude.Include.NON_NULL)
val title:String?="",
val artist:String?="",
val duration: String?="",
val tagU:Int? =null
)
override fun addMusic(music: Musics){
transaction {
Music.insert{
it[title]= music.title ?:""
it[artist]=music.artist?:""
it[duration]=music.duration?:""
it[tagU]=music.tagU?:0
}
}
}
ESchouten
05/26/2021, 9:58 PMSlackbot
05/30/2021, 11:32 AMninad thakare
05/30/2021, 1:25 PMDebanshu Datta
05/30/2021, 5:12 PMJoão Rodrigues
06/01/2021, 9:55 AMcuongtd
06/05/2021, 5:20 AMjmfayard
06/07/2021, 5:04 PMSlackbot
06/10/2021, 2:29 AMSergey
06/10/2021, 7:17 PMMichael Grigoryan
06/11/2021, 6:31 PMHafs
06/12/2021, 9:15 PMVoytech
06/13/2021, 12:14 PMPavel Petkevich
06/14/2021, 5:01 PMLena Stepanova
06/16/2021, 9:45 AMHusam
06/18/2021, 12:22 PMchristophsturm
06/21/2021, 9:33 AMreperion.kim
06/22/2021, 1:02 AMCisino da Silva Gomes Junior
06/25/2021, 6:19 PMiamraghavawasthi
06/28/2021, 7:17 PMLuiz Aguiar
06/30/2021, 10:15 PMjmfayard
07/02/2021, 8:57 AMРолан
07/06/2021, 11:44 AMAmitav Khandelwal
07/08/2021, 9:19 AMdata class
es, like Step1Output
, which becomes the input for step 2, and so on. I’ve managed to make the step functions are pure functions this way, which I believe is a best practice.
My problem now is that in case I need to introduce anything new in the output that requires another piece of data from the input, I need to modify all my StepXOutput
classes and keep passing on the data between them. This obviously makes doing any changes slow and painful.
Any ideas on design patterns that can help with this? Or is there some well-architected, complex project that I can look at for reference? Thanks!Amitav Khandelwal
07/08/2021, 9:19 AMdata class
es, like Step1Output
, which becomes the input for step 2, and so on. I’ve managed to make the step functions are pure functions this way, which I believe is a best practice.
My problem now is that in case I need to introduce anything new in the output that requires another piece of data from the input, I need to modify all my StepXOutput
classes and keep passing on the data between them. This obviously makes doing any changes slow and painful.
Any ideas on design patterns that can help with this? Or is there some well-architected, complex project that I can look at for reference? Thanks!nfrankel
07/08/2021, 9:23 AMmight be more general software than kotlin/spring.it is general design hence... :not-kotlin:
Amitav Khandelwal
07/08/2021, 9:25 AMkqr
07/08/2021, 10:44 AMAmitav Khandelwal
07/08/2021, 10:46 AMkqr
07/08/2021, 12:05 PMQuincy
07/08/2021, 12:56 PMdata class Step1Output(...)
you just passed around a Map<String, Any>
? You still need to deal with setting and accessing any new keys you put into the map later on, but nothing about how you transport the data needs to change. It's just a map.
If you have a need for a nested map, i.e., your existing data classes aren't just full of primitives, then you could wrap the map in a class the lets you more easily access the nested values.
For example:
outputMap.getValue("/firstKey/secondKey/thirdKey")
instead of
outputMap.get("firstKey")?.get("secondKey")?.get("thirdKey")
In projects I work on we've had a lot of success in the past using classes that delegate to a map as well.
data class Foo(map: Map<String, Any>): Map<String, Any> by map
You can add functions to Foo
to make certain patterns of data access easier, but you still get to treat it like a map. You can even add functions to set and retrieve values in a type safe way if that's important to you.nkiesel
07/08/2021, 4:15 PMAddressVerificationInput
/ AddressVerificationOutput
. This makes it much clearer what the data structures are use for, and if you e.g. break that step into "billing address" and "home address" steps, you only have to change this step.
Regarding using a map: we used that in our legacy system, and I hate it with passion: no type safety, refactoring is horribly complicated (esp. if developers get creative by creating "dynamic key computation functions"), and just try to find all the places where your "id" key/value pair is used.edrd
07/08/2021, 8:02 PMQuincy
07/09/2021, 1:42 PMDALDEI
10/03/2021, 3:02 AM