From 08bfaef4f14217b0b41cb77a2661935f3b3dcfe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wieczorek?= Date: Mon, 4 Sep 2023 16:48:40 +0200 Subject: [PATCH 1/3] Add more info about favicon.ico. --- docs/getting-started/folder-structure.md | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/getting-started/folder-structure.md b/docs/getting-started/folder-structure.md index 6802fced3..87e2e5832 100644 --- a/docs/getting-started/folder-structure.md +++ b/docs/getting-started/folder-structure.md @@ -35,6 +35,35 @@ let fileMiddleware = FileMiddleware( app.middleware.use(fileMiddleware) ``` +If running from Xcode please set the project schema run option working directory. +See [here](https://docs.vapor.codes/getting-started/xcode/#custom-working-directory) for more information. + +To see the `favicon.ico` in action prepare a route in `/Sources/App/routes.swift` like this: + +```swift +import Vapor + +func routes(_ app: Application) throws { + app.get { req async in + Response( + status: .ok, + headers: ["Content-Type": "text/html"], + body: + """ + + + + + + It works! + + + """ + ) + } +} +``` + ## Sources This folder contains all of the Swift source files for your project. From 02e694e0e3aad2e1b227c6a22279a83ee268dc8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wieczorek?= Date: Mon, 4 Sep 2023 18:58:54 +0200 Subject: [PATCH 2/3] Fix Markdown document path. --- docs/getting-started/folder-structure.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started/folder-structure.md b/docs/getting-started/folder-structure.md index 87e2e5832..17f82e53f 100644 --- a/docs/getting-started/folder-structure.md +++ b/docs/getting-started/folder-structure.md @@ -36,7 +36,7 @@ app.middleware.use(fileMiddleware) ``` If running from Xcode please set the project schema run option working directory. -See [here](https://docs.vapor.codes/getting-started/xcode/#custom-working-directory) for more information. +See [here](xcode.md#custom-working-directory) for more information. To see the `favicon.ico` in action prepare a route in `/Sources/App/routes.swift` like this: From 5892ce34a144175b47e4de21aa117aa89825c5a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wieczorek?= Date: Tue, 5 Sep 2023 12:17:12 +0200 Subject: [PATCH 3/3] Move favicon sample to middleware docs. --- docs/advanced/middleware.md | 27 ++++++++++++++++++++++++ docs/getting-started/folder-structure.md | 25 ---------------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/docs/advanced/middleware.md b/docs/advanced/middleware.md index 3d5ea4e03..a74c47b37 100644 --- a/docs/advanced/middleware.md +++ b/docs/advanced/middleware.md @@ -132,6 +132,33 @@ let file = try FileMiddleware(bundle: .main, publicDirectory: "Public") Also make sure to use Folder References instead of Groups in Xcode to maintain folder structure in resources after building the application. + +The following code from `/Sources/App/routes.swift` can be used with a `favicon.ico` put in `Public/`. The icon of your choosing should be visible on your tab in a browser if you visit the server root resource. + +```swift +import Vapor + +func routes(_ app: Application) throws { + app.get { req async in + Response( + status: .ok, + headers: ["Content-Type": "text/html"], + body: + """ + + + + + + It works! + + + """ + ) + } +} +``` + ## CORS Middleware Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served. REST APIs built in Vapor will require a CORS policy in order to safely return requests to modern web browsers. diff --git a/docs/getting-started/folder-structure.md b/docs/getting-started/folder-structure.md index 17f82e53f..03e6b1862 100644 --- a/docs/getting-started/folder-structure.md +++ b/docs/getting-started/folder-structure.md @@ -38,31 +38,6 @@ app.middleware.use(fileMiddleware) If running from Xcode please set the project schema run option working directory. See [here](xcode.md#custom-working-directory) for more information. -To see the `favicon.ico` in action prepare a route in `/Sources/App/routes.swift` like this: - -```swift -import Vapor - -func routes(_ app: Application) throws { - app.get { req async in - Response( - status: .ok, - headers: ["Content-Type": "text/html"], - body: - """ - - - - - - It works! - - - """ - ) - } -} -``` ## Sources