Skip to content

Instantly share code, notes, and snippets.

@digimon1740
Created August 31, 2019 13:10
Show Gist options
  • Select an option

  • Save digimon1740/b3bf69afabbf9d4ad153d128c75e6937 to your computer and use it in GitHub Desktop.

Select an option

Save digimon1740/b3bf69afabbf9d4ad153d128c75e6937 to your computer and use it in GitHub Desktop.
package com.digimon.demo.router
import com.digimon.demo.handler.TodoHandler
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.web.reactive.function.server.RequestPredicates.path
import org.springframework.web.reactive.function.server.RouterFunctions.nest
import org.springframework.web.reactive.function.server.router
@Configuration
class TodoRouter(private val handler: TodoHandler) {
@Bean
fun routerFunction() = nest(path("/todos"),
router {
listOf(
GET("/", handler::getAll),
GET("/{id}", handler::getById),
POST("/", handler::save),
PUT("/{id}/done", handler::done),
DELETE("/{id}", handler::delete))
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment