Skip to content

Commit

Permalink
Added Static Files to Autorouter
Browse files Browse the repository at this point in the history
  • Loading branch information
bsautner committed Feb 13, 2025
1 parent b4e3c9d commit af3e308
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ class RouteGenerator() {

fun createStaticGetRoute(metaData: ClassMetaData) {
val block = CodeBlock.Companion.builder()

ImportManager.addRouterImport("java.io", "File")
metaData.declaration.annotations.firstOrNull { it.shortName.asString() == Resource::class.simpleName }?.let {
it.arguments.firstOrNull { check -> check.name?.asString() == PATH}?.let { resource ->
metaData.declaration.annotations.firstOrNull { it.shortName.asString() == KoboldStatic::class.simpleName }?.let {
it.arguments.firstOrNull { check -> check.name?.asString() == PATH }?.let { path ->
block. beginControlFlow("staticResources(%S, %S)", resource.value, path.value)
block.beginControlFlow("staticFiles(%S, File(%S))", resource.value, path.value)
.addStatement("default(%S)", "index.html")
. endControlFlow()
}
Expand Down

0 comments on commit af3e308

Please sign in to comment.