You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 4, 2025. It is now read-only.
Hello, this is quite a fantastic library you've made available!
The only thing I haven't been able to figure out from the examples available + source code is whether it's possible to programmatically/dynamically create new routes?
To test this, I tried to have an endpoint /sample create a route /new, but what gets returned is just the empty "whitelabel" page.
This is with Spring Boot 2.6-SNAPSHOT and the 0.4.5-SNAPSHOT of Spring-Fu:
packageorg.hasura.polyglotimportscala.beans.BeanPropertyimportreactor.core.publisher.Monoimportorg.springframework.fu.jafu.Jafu.reactiveWebApplicationimportorg.springframework.fu.jafu.webflux.WebFluxServerDslimportorg.springframework.fu.jafu.webflux.WebFluxServerDsl.webFluximportorg.springframework.web.reactive.function.server.ServerRequestimportorg.springframework.web.reactive.function.server.ServerResponseimportorg.springframework.web.reactive.function.server.ServerResponse.okimportorg.springframework.web.reactive.function.server.RouterFunctionscaseclassSample(@BeanPropertymessage: String)
classSampleService:defgenerateMessage():String="Hello world!"classSampleHandler(privatevarsampleService:SampleService):defhello(request: ServerRequest):Mono[ServerResponse] =ServerResponse.ok().bodyValue(sampleService.generateMessage())
defjson(request: ServerRequest):Mono[ServerResponse] =ServerResponse.ok().bodyValue(newSample(sampleService.generateMessage()))
defmkRoutes(server: WebFluxServerDsl)(app: RouterFunctions.Builder) =valhandler= server.ref(classOf[SampleHandler])
app.GET("/sample", req => {
println("Called /sample handler, attempting to dynamically create endpoint...")
app.GET("/new", req => {
println("/new endpoint created from within /sample")
ServerResponse.ok().bodyValue("dynamically created during GET /sample request")
})
ServerResponse.ok().bodyValue("hello")
})
app.GET("/", req => {
handler.hello(req)
})
app.GET("/api", handler.json)
objectApplication:valapp= reactiveWebApplication(a => {
a.beans(b => {
b.bean(classOf[SampleHandler])
b.bean(classOf[SampleService])
})
a.enable(
webFlux(server =>
server
.port(if server.profiles().contains("test") then8181else8080)
.router(mkRoutes(server))
.codecs(_.string().jackson())
)
)
})
defmain(args: Array[String]):Unit= app.run(args)
Hello, this is quite a fantastic library you've made available!
The only thing I haven't been able to figure out from the examples available + source code is whether it's possible to programmatically/dynamically create new routes?
To test this, I tried to have an endpoint
/samplecreate a route/new, but what gets returned is just the empty "whitelabel" page.This is with Spring Boot 2.6-SNAPSHOT and the 0.4.5-SNAPSHOT of Spring-Fu: