Closed xielibin closed 7 years ago
@iamjono
First, clone PerfectTemplate project and add
routes.add(method: .get, uri: "/**", handler: {
request, response in
StaticFileHandler(documentRoot: request.documentRoot).handleRequest(request: request, response: response)
})
to main.swift file.
Second, build PerfectTemplate and launch project, add a test.html file to ./webroot directory. Next, request http://localhost:8181/test.html, then the func handleRequest in StaticFileHandler
var path = request.path
the path is "/test.html" and documentRoot is "./webroot", so 'documentRoot + "/" + path' is "./webroot//test.html", the file will not be found.
Thanks @xielibin - could you submit a use case where this is an issue please?