当前位置:嗨网首页>书籍在线阅读

19-使用Kotlin调用Spring Web的功能性API

  
选择背景色: 黄橙 洋红 淡粉 水蓝 草绿 白色 选择字体: 宋体 黑体 微软雅黑 楷体 选择字体大小: 恢复默认

17.9.2 使用Kotlin调用Spring Web的功能性API

Spring Framework 5.0提供了一种更加简单的路由调用方式,可以让开发者更简单优雅地使用Kotlin代码来调用Spring的函数式 API。

 ("/blog" and accept(TEXT_HTML)).route {
           GET("/", this@BlogController::findAllView)
           GET("/{slug}", this@BlogController::findOneView)
    }
    ("/api/blog" and accept(APPLICATION_JSON)).route {
           GET("/", this@BlogController::findAll)
           GET("/{id}", this@BlogController::findOne)
}