ktorio / ktor

Framework for quickly creating connected applications in Kotlin with minimal effort

Home Page:https://ktor.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ktor static resource issue

Kotlin-GDE opened this issue · comments

hi

i create index.html inside static folder in ktor project (resources/static) and i config static resource like this:

static("static") {
            default("static/index.html")
        }

when invoke http://localhost:8080/static, i expected to show index.html but response 404 appear (resource not found)

Is not a bug. You are using resources not file so you should use

static("static") {
          resources("static")
           defaultResource("static/index.html")
        }

cf doc: https://ktor.io/servers/features/static-content.html#serving-embedded-resources

Too bad I was hopping to make it my first PR ;)

but in ktor documentation, it's motioned like that

We can also have default files that can be served using default. For instance, on calling
/static with no filename, index.html will be served