-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support routers which inject beans (#67)
- Loading branch information
1 parent
7904bd9
commit f8f5424
Showing
8 changed files
with
102 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
spring-funk-webmvc/src/main/kotlin/com/github/wakingrufus/funk/webmvc/RoutesDsl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.github.wakingrufus.funk.webmvc | ||
|
||
import com.github.wakingrufus.funk.core.SpringDslMarker | ||
import org.springframework.context.support.BeanDefinitionDsl | ||
import org.springframework.web.servlet.function.RouterFunction | ||
import org.springframework.web.servlet.function.RouterFunctionDsl | ||
import org.springframework.web.servlet.function.ServerResponse | ||
|
||
@SpringDslMarker | ||
class RoutesDsl { | ||
private val routes = mutableListOf<BeanDefinitionDsl.BeanSupplierContext.() -> RouterFunction<ServerResponse>>() | ||
|
||
@SpringDslMarker | ||
fun router(f: BeanDefinitionDsl.BeanSupplierContext.() -> RouterFunction<ServerResponse>) { | ||
routes.add(f) | ||
} | ||
|
||
@SpringDslMarker | ||
fun route(router: RouterFunctionDsl.() -> Unit) { | ||
routes.add { org.springframework.web.servlet.function.router(router) } | ||
} | ||
|
||
internal fun merge(f: BeanDefinitionDsl.BeanSupplierContext): RouterFunction<ServerResponse> = | ||
routes.map { it.invoke(f) }.reduce(RouterFunction<ServerResponse>::and) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters