X-Git-Url: http://nitlanguage.org diff --git a/lib/nitcorn/file_server.nit b/lib/nitcorn/file_server.nit index 348383e..0245d1f 100644 --- a/lib/nitcorn/file_server.nit +++ b/lib/nitcorn/file_server.nit @@ -21,6 +21,7 @@ module file_server import reactor import sessions import media_types +import http_errors redef class String # Returns a `String` copy of `self` without any of the prefixed '/'s @@ -41,9 +42,38 @@ end class FileServer super Action - # Root of `self` file system + # Root folder of `self` file system var root: String + init + do + var root = self.root + + # Simplify the root path as each file requested will also be simplified + root = root.simplify_path + + # Make sure the root ends with '/', this makes a difference in the security + # check on each file access. + root = root + "/" + + self.root = root + end + + # Error page template for a given `code` + fun error_page(code: Int): Writable do return new ErrorTemplate(code) + + # Header of each directory page + var header: nullable Writable = null is writable + + # Custom JavaScript code added within a ` {{{title}}} + {{{header_code}}}

{{{title}}}