From ad8fc197500dbcecf909a929d6eeb14fcd0a1db6 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Wed, 11 Nov 2020 18:11:12 -0800 Subject: [PATCH] Add error pages --- .../contents.xcworkspacedata | 7 ----- Resources/Views/404.leaf | 24 ++++++++++++++ Resources/Views/serverError.leaf | 31 +++++++++++++++++++ Sources/App/configure.swift | 2 +- 4 files changed, 56 insertions(+), 8 deletions(-) delete mode 100644 .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata create mode 100644 Resources/Views/404.leaf create mode 100644 Resources/Views/serverError.leaf diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a..0000000 --- a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Resources/Views/404.leaf b/Resources/Views/404.leaf new file mode 100644 index 0000000..032115b --- /dev/null +++ b/Resources/Views/404.leaf @@ -0,0 +1,24 @@ + + + + Not Found + + + + + + +
+
+
+
404
+

This page wasn't found on our server

+

Either the page was removed or you clicked on a bad link…

+ + Go back + +
+
+
+ + diff --git a/Resources/Views/serverError.leaf b/Resources/Views/serverError.leaf new file mode 100644 index 0000000..5b1261c --- /dev/null +++ b/Resources/Views/serverError.leaf @@ -0,0 +1,31 @@ + + + + + #(statusMessage) + + + + + + +
+
+
+
#(status)
+

+ #if(reason ?? false): + #(reason) + #else: + #(statusMessage) + #endif +

+

If you have done everything properly, please try again later…

+ + Go back + +
+
+
+ + \ No newline at end of file diff --git a/Sources/App/configure.swift b/Sources/App/configure.swift index 09f09a7..def716c 100644 --- a/Sources/App/configure.swift +++ b/Sources/App/configure.swift @@ -4,9 +4,9 @@ import LeafErrorMiddleware // configures your application public func configure(_ app: Application) throws { + app.middleware.use(LeafErrorMiddleware()) // Serve files from /Public app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory)) - app.middleware.use(LeafErrorMiddleware()) // Configure Leaf LeafOption.caching = app.environment.isRelease ? .default : .bypass