【发布时间】:2018-02-14 20:56:12
【问题描述】:
我想使用 Kitura 查看 localhost 目录中的文件。 我写过:
router.all("/test/*", middleware: StaticFileServer())
但它似乎没有工作
我想要我目录中的所有文件。类似于 directoryIndex
【问题讨论】:
标签: swift localhost fileserver kitura server-side-swift
我想使用 Kitura 查看 localhost 目录中的文件。 我写过:
router.all("/test/*", middleware: StaticFileServer())
但它似乎没有工作
我想要我目录中的所有文件。类似于 directoryIndex
【问题讨论】:
标签: swift localhost fileserver kitura server-side-swift
您可以将要服务的目录的路径传递给StaticFileServer,作为path参数,默认为"public":
router.all("/test/", middleware: StaticFileServer(path: "MyDirectoryWithStaticFiles"))
然后您将能够访问该目录中的文件,但不能访问该目录本身。例如,您将能够执行 GET /test/someFile.html,但不能执行 /test/。如果您的目录包含index.html,您将能够获取/test/。
请参阅https://github.com/IBM-Swift/Kitura-Sample,例如使用StaticFileHandler。
【讨论】: