tribune icon indicating copy to clipboard operation
tribune copied to clipboard

spike for spring example

Open clojj opened this issue 2 years ago • 24 comments

Hi, and first kudos for adding these handlers (for Ktor) !

This may not yet be complete.. just to start somewhere with a spring example. Obviously, the spring specifics will have to move to a new module "tribune-spring" (in the works).

So what do you think ?

At some point, when arrow-proofs (Kotlin must have a stable IR) is ready, I'd alos like to explore that route. Plain Kotlin context receivers may be a valuable addition too, but I am still exploring that (that's why I left the compiler arg for it in the grable build)

clojj avatar Aug 23 '22 21:08 clojj

I like it.

We should make the tribune-spring module you mentioned. Do you want me to merge this first ?

sksamuel avatar Aug 24 '22 03:08 sksamuel

Hi, no merge yet. I will fix some quirks and add the spring module first....

clojj avatar Aug 24 '22 06:08 clojj

just commented my todo's in spring.kt

clojj avatar Aug 24 '22 07:08 clojj

I don't see any todos ?

sksamuel avatar Aug 24 '22 07:08 sksamuel

I used Github Mobile App and commented in source spring.kt, never mind..I will commit later

Sam @.***> schrieb am Mi., 24. Aug. 2022, 09:55:

I don't see any todos ?

— Reply to this email directly, view it on GitHub https://github.com/sksamuel/tribune/pull/17#issuecomment-1225334965, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBKMW7VDK42HIH2PQPXH5TV2XIOTANCNFSM57M65N7A . You are receiving this because you modified the open/close state.Message ID: @.***>

clojj avatar Aug 24 '22 08:08 clojj

:( @JsonUnwrapped doesn't seem to work with Kotlin, noooooo......!

clojj avatar Aug 24 '22 22:08 clojj

What's json unwrapped do ?

sksamuel avatar Aug 25 '22 18:08 sksamuel

It would not serialize a field of a complex type, instead it would just directly serialize the complex type.

For my spring endpoint example, I would like to return a properly typed result, and neither ResponseEntity<Any> nor implement a custom Validated serializer. So my generic Response type should cover the 2 cases of Validated, but should not pollute the json with its properties.

clojj avatar Aug 25 '22 19:08 clojj

The good guys from arrow-kt have a Jackson lib, which covers several arrow types. So devs can use that, if they actually want to return "wrapped" responses.

Ultimately, tribune-spring should be flexibel and offer ways to respond according to APIs needs

clojj avatar Aug 25 '22 20:08 clojj

So essentially you were trying to create the spring version of my ktor "handler" ?

sksamuel avatar Aug 26 '22 11:08 sksamuel

Almost.. your Handler ha unit return type, which is not possible with Spring RestController methods.

clojj avatar Aug 26 '22 19:08 clojj

@sksamuel Issue with JsonUnwrapped resolved, I'll try to polish this PR soon

clojj avatar Aug 29 '22 15:08 clojj

Cool

On Mon, 29 Aug 2022 at 10:55, clojj @.***> wrote:

@sksamuel https://github.com/sksamuel Issue with JsonUnwrapped resolved, I'll try to polish this PR soon

— Reply to this email directly, view it on GitHub https://github.com/sksamuel/tribune/pull/17#issuecomment-1230506610, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGXVHC73D63D4SLHXI3V3TMORANCNFSM57M65N7A . You are receiving this because you were mentioned.Message ID: @.***>

sksamuel avatar Aug 29 '22 16:08 sksamuel

Apart from being an example/teaser for spring folks, the basic question seems what real-world features such a handler can bring to the table: if it should serve as a generic "protection layer" in API controllers, return type and configurability stand out to me...

clojj avatar Aug 30 '22 06:08 clojj

@sksamuel first shot at trubune-spring module

clojj avatar Aug 30 '22 06:08 clojj

Would this return a 200 for both error and success?

sksamuel avatar Aug 30 '22 07:08 sksamuel

Would this return a 200 for both error and success?

no, the jsonResponseHandler will return 404

clojj avatar Aug 30 '22 07:08 clojj

I am really struggling with gradle-multiplatform... weird messages in IntelliJ, restart fixes them, gives me the feeling of 'only works on my machine' Get the message "...missing wrapper" should/must I add a /gradle/wrapper subdir for tribune-spring ?

clojj avatar Aug 30 '22 14:08 clojj

Just refactored the handler to make it more generic

clojj avatar Aug 31 '22 15:08 clojj

there probably is a better alternative to having nullable parameters for each parse-outcome, but hey.. it's Kotlin :)

clojj avatar Aug 31 '22 15:08 clojj

got rid of that nullables + fixed response code

clojj avatar Sep 01 '22 11:09 clojj

There should also probably be a reactive-spring example later, as we are preferrably in suspend land :)

clojj avatar Sep 01 '22 11:09 clojj

@sksamuel I think this is could be ready for merge, what do you think ?

clojj avatar Sep 04 '22 17:09 clojj

I'll check it out.

On Sun, 4 Sept 2022 at 12:09, clojj @.***> wrote:

@sksamuel https://github.com/sksamuel I think this is could be ready for merge, what do you think ?

— Reply to this email directly, view it on GitHub https://github.com/sksamuel/tribune/pull/17#issuecomment-1236381332, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGWTOM3XO55D7SIGAGDV4TJV5ANCNFSM57M65N7A . You are receiving this because you were mentioned.Message ID: @.***>

sksamuel avatar Sep 04 '22 17:09 sksamuel

This is nice. Pity we need the wrapper json but otherwise slick.

sksamuel avatar Oct 03 '22 01:10 sksamuel

Ok cool.

On Wed, 24 Aug 2022 at 01:19, clojj @.***> wrote:

Hi, no merge yet. I will fix some quirks and add the spring module first....

— Reply to this email directly, view it on GitHub https://github.com/sksamuel/tribune/pull/17#issuecomment-1225249491, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGVGAJFRI2OTH4XEECTV2W5FJANCNFSM57M65N7A . You are receiving this because you commented.Message ID: @.***>

sksamuel avatar Oct 11 '22 07:10 sksamuel