Git Product home page Git Product logo

spring-kotlin-functional's Introduction

This project is designed to demonstrate:

This sample does not use functional bean registration for 3 main reasons:

  • This is not yet well supporting with native/AOT, see spring-framework#29555 related issue.
  • Spring Fu development is frozen while the Spring team figures out a better option to provide first class support for functional configuration well integrated in Spring Boot, see spring-boot#8115 related issue.
  • Spring AOT transforms automatically annotation-based JavaConfig configuration model to functional bean registration executed at runtime.

Getting started

  • Build the project and run tests with ./gradlew build
  • Run the application with ./gradlew bootRun
  • Create a native executable with ./gradlew nativeCompile then run build/native/nativeCompile/spring-kotlin-functional executable (add .exe on Windows)
  • Build an optimized native container with ./gradlew bootBuildImage

AOT on the JVM

AOT generation happens when either id("org.graalvm.buildtools.native") or id("org.springframework.boot.aot") plugins are activated.

If you want to leverage to speedup the application startup on the JVM:

  • Unpack the executable JAR with jar -xf myapp.jar as documented here
  • Run the java command with -Dspring.aot.enabled=true, for example java -Dspring.aot.enabled=true -cp BOOT-INF/classes:BOOT-INF/lib/* com.example.MyApplication

spring-kotlin-functional's People

Contributors

sdeleuze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-kotlin-functional's Issues

exception handler - example

@sdeleuze i'd like to register an exception handler that transforms an exception into a json response.

for example, I'd like to create a custom WebExceptionHandler that upon receiving an exception e.g. Exception("oh snap! something went wrong"), it return a json response e.g.

 {
   "code": "internal_server_error",
   "message": "oh snap something went wrong"
}

i see the default exception strategy does this

public Mono<Void> handle(ServerWebExchange exchange, Throwable ex) {
	if (ex instanceof ResponseStatusException) {
		exchange.getResponse().setStatusCode(((ResponseStatusException) ex).getStatus());
		logger.debug(ex.getMessage());
		return exchange.getResponse().setComplete();
	}
	return Mono.error(ex);
}

All in all, its not clear to me how to respond with json from the exception handler. It seems like i must transform the exception into a DataBuffer, however this seems fairly complicated.

Any ideas? An example would be greatly appreciated!

Also, thanks so much for this example project. I've found it super helpful.

CORS configuration

Hey @sdeleuze, thank you for cool project.
I have question about CORS in your Netty configuration by Kotlin DSL - could you add CORS filter in project?

Thanks

build.gradle.kts all red

I download this code,and the build.gradle.kts file was all red ,idea prompt unresolved reference:kotlin,can you tell me why,thank you !

Add MongoDB support

Add MongoDB Reactive support by providing a functional alternative to <repositories base-package="com.acme.repositories" /> in order to register MongoRepositoryFactoryBean (and possibliy other required beans). This could be maybe integrated in Spring Data natively later.

Pull requests welcomed!

Executable Jar Issue

Running the commands given for building and running:

  1. ./gradlew clean build shadowJar
  2. java -jar build/libs/spring-kotlin-functional-1.0.0-SNAPSHOT-all.jar

Results in:

no main manifest attribute, in build/libs/spring-kotlin-functional-1.0.0-SNAPSHOT-all.jar

Kotlin-Routing

Can the more best way of this code?

fun router() = router {
GET("/{a}", proxyHandler::redirect)
GET("/{a}/", proxyHandler::redirect)
GET("/{a}/{b}", proxyHandler::redirect)
GET("/{a}/{b}/", proxyHandler::redirect)
GET("/{a}/{b}/{c}", proxyHandler::redirect)
GET("/{a}/{b}/{c}/", proxyHandler::redirect)
GET("/{a}/{b}/{c}/{d}", proxyHandler::redirect)
GET("/{a}/{b}/{c}/{d}/", proxyHandler::redirect)
GET("/{a}/{b}/{c}/{d}/{e}", proxyHandler::redirect)
GET("/{a}/{b}/{c}/{d}/{e}/", proxyHandler::redirect)
GET("/{a}/{b}/{c}/{d}/{e}/{f}", proxyHandler::redirect)
GET("/{a}/{b}/{c}/{d}/{e}/{f}/", proxyHandler::redirect)
POST("/{a}", proxyHandler::redirect)
POST("/{a}/", proxyHandler::redirect)
POST("/{a}/{b}", proxyHandler::redirect)
POST("/{a}/{b}/", proxyHandler::redirect)
POST("/{a}/{b}/{c}", proxyHandler::redirect)
POST("/{a}/{b}/{c}/", proxyHandler::redirect)
POST("/{a}/{b}/{c}/{d}", proxyHandler::redirect)
POST("/{a}/{b}/{c}/{d}/", proxyHandler::redirect)
POST("/{a}/{b}/{c}/{d}/{e}", proxyHandler::redirect)
POST("/{a}/{b}/{c}/{d}/{e}/", proxyHandler::redirect)
POST("/{a}/{b}/{c}/{d}/{e}/{f}", proxyHandler::redirect)
POST("/{a}/{b}/{c}/{d}/{e}/{f}/", proxyHandler::redirect)

Link Functional bean definition with Kotlin DSL (no reflection, no CGLIB proxies involved) in readme is broken

The link leads to https://github.com/sdeleuze/spring-kotlin-functional/blob/master/src/main/kotlin/micro/Beans.kt which gives 404. Maybe this is the right one ? https://github.com/sdeleuze/spring-kotlin-functional/blob/master/src/main/kotlin/functional/Beans.kt

Other links have the same problem: WebFlux functional routing declaration with Kotlin DSL and Junit 5 @BeforeAll and @afterall on non-static methods in Kotlin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.