Ktor 中的静态文件和嵌入式应用资源有什么区别?

What is the difference between static files and embedded application resources in Ktor?

我正在阅读 ktor documentation on serving static content,但我不清楚 files("css")resources("css") 之间的区别。

static方法等同于route方法,只是在路由树中创建一条path路由。

files 方法允许从本地文件系统提供的路径(目录)提供所有静态文件。将使用当前工作目录解析相对路径。

resources 方法与 files 方法的作用相同,只是它允许从类路径提供静态文件。

这是一个例子:

// Assume that current working directory is /home/user/project
embeddedServer(Netty, port = 8080) {
    routing {
        // This route will be resolved if a request path starts with /assets/
        static("assets") {
            // For the request path /assets/style.css the file /home/user/project/css/style.css will be served
            files("./css")
            // It's the same as above
            files("css")
            // For the request path /assets/data.txt the file /absolute/path/to/data.txt will be served
            files("/absolute/path/to")

            // For the request path /assets/style.css the file <resources>/css/style.css will be served
            // where <resources> is the embedded resource directory
            resources("css")
        }
    }
}.start(wait = true)