MarkdownConverter: Kotlin function type
This commit is contained in:
committed by
Sébastien Deleuze
parent
4544e8f81f
commit
366373db63
@@ -32,8 +32,8 @@ class HtmlController(private val repository: ArticleRepository,
|
||||
|
||||
fun Article.render() = RenderedArticle(
|
||||
title,
|
||||
markdownConverter.invoke(headline),
|
||||
markdownConverter.invoke(content),
|
||||
markdownConverter(headline),
|
||||
markdownConverter(content),
|
||||
author,
|
||||
id,
|
||||
addedAt.format()
|
||||
|
||||
@@ -13,8 +13,8 @@ class ArticleController(private val repository: ArticleRepository,
|
||||
@GetMapping("/{id}")
|
||||
fun findOne(@PathVariable id: Long, @RequestParam converter: String?) = when (converter) {
|
||||
"markdown" -> repository.findById(id).map { it.copy(
|
||||
headline = markdownConverter.invoke(it.headline),
|
||||
content = markdownConverter.invoke(it.content)) }
|
||||
headline = markdownConverter(it.headline),
|
||||
content = markdownConverter(it.content)) }
|
||||
null -> repository.findById(id)
|
||||
else -> throw IllegalArgumentException("Only markdown converter is supported")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user