Merge: nitcorn: FileServer default file
authorJean Privat <jean@pryen.org>
Thu, 26 May 2016 23:55:27 +0000 (19:55 -0400)
committerJean Privat <jean@pryen.org>
Thu, 26 May 2016 23:55:27 +0000 (19:55 -0400)
This PR introduce the concept of default file in `FileServer`. This allow the user to specify what file to return instead of the 404 page if no file matches the query.

Pull-Request: #2127
Reviewed-by: Jean Privat <jean@pryen.org>

lib/core/file.nit

index def1cd2..7f1d481 100644 (file)
@@ -663,6 +663,19 @@ class Path
                return res
        end
 
+       # Is `self` the path to an existing directory ?
+       #
+       # ~~~nit
+       # assert ".".to_path.is_dir
+       # assert not "/etc/issue".to_path.is_dir
+       # assert not "/should/not/exist".to_path.is_dir
+       # ~~~
+       fun is_dir: Bool do
+               var st = stat
+               if st == null then return false
+               return st.is_dir
+       end
+
        # Delete a directory and all of its content
        #
        # Does not go through symbolic links and may get stuck in a cycle if there