Skip to content

update content-improvments branch per feedback #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions _data/go_further.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
content_url: https://developer.apple.com/videos/play/wwdc2021/10132/
thumbnail_url: #TBD
release_date: 2021-06-08
- title: "Swift Generics"
- title: "Generics"
description: "In Swift, generics are a fundamental way to write abstract code. This video walks through the basics of Swift Generics and introducing generics into your code."
content_type: video
content_url: https://developer.apple.com/videos/play/wwdc2021/10132/
Expand All @@ -16,7 +16,7 @@
content_url: https://developer.apple.com/videos/play/wwdc2022/110357/
thumbnail_url: #TBD
release_date: 2022-06-07
- title: "Swift Strings Under The Hood"
- title: "Strings Under The Hood"
description: "Swift strings provide a fast, Unicode-compliant way to work with text. This article provides more detail on how strings are implemented in Swift using UTF-8 and the reasons behind that choice."
content_type: article
content_url: /blog/utf8-string/
Expand Down
2 changes: 1 addition & 1 deletion documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ If you are new to Swift, you may want to check out these additional resources.

<div class="links links-list-nostyle" markdown="1">
- [Getting started guide](/getting-started/)
- [Swift resources at Apple.com](https://developer.apple.com/swift/resources/){:target="_blank" class="link-external"}
- [Swift resources on developer.apple.com](https://developer.apple.com/swift/resources/){:target="_blank" class="link-external"}
</div>

## Swift Language
Expand Down
10 changes: 5 additions & 5 deletions getting-started/_use-cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Looking for a language reference? [The Swift Programming Language (TSPL)](https:
<li class="use-case">
<h3>Command-line Tool</h3>
<p class="description">
Build a command-line tool using SwiftPM.
Build a cross-platform command-line tool.
</p>

<a href="/getting-started/cli-swiftpm" class="cta-secondary">Start tutorial</a>
Expand All @@ -18,24 +18,24 @@ Looking for a language reference? [The Swift Programming Language (TSPL)](https:
<li class="use-case">
<h3>Library</h3>
<p class="description">
Build a library using SwiftPM.
Build a cross-platform library.
</p>

<a href="/getting-started/library-swiftpm" class="cta-secondary">Start tutorial</a>
</li>

<li class="use-case">
<h3>Web Server with Vapor</h3>
<h3>Web Service</h3>
<p class="description">
Use the open-source Vapor framework to build a web service using SwiftPM.
Use a web framework to build a web service.
Requires macOS or Linux.
</p>

<a href="/getting-started/vapor-web-server" class="cta-secondary">Start tutorial</a>
</li>

<li class="use-case">
<h3>App for Apple platforms</h3>
<h3>iOS and macOS Application</h3>
<p class="description">
Use Swift and SwiftUI to build an app that works on iOS and macOS.
Requires macOS 12 and Xcode 14.
Expand Down
12 changes: 9 additions & 3 deletions getting-started/vapor-web-server/index.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
---
layout: page
title: Build a Web Server with Vapor
title: Build a Web Service with Vapor
---

{% include getting-started/_installing.md %}

## Choosing a web framework

Over the years, the Swift community created several web frameworks designed to help building web services.
This guide focuses on the [Vapor](https://vapor.codes) web framework, a popular choice with the community.

## Installing Vapor

This guide uses the [Vapor](https://vapor.codes) web framework to build a server application. First, you need to install the Vapor toolbox. If you already have Homebrew installed on macOS, run
First, you need to install the Vapor toolbox.
If you already have Homebrew installed on macOS, run

```bash
brew install vapor
Expand Down Expand Up @@ -57,7 +63,7 @@ app.get("hello", ":name") { req async throws -> String in
}
```

Here's what the code does:
Here's what the code does:

1. Declare a new route handler registered as a **GET** request to `/hello/<NAME>`. The `:` denotes a dynamic path parameter in Vapor and will match any value and allow you to retrieve it in your route handler. `app.get(...)` takes a closure as the final parameter that can be asynchronous and must return a `Response` or something conforming to `ResponseEncodable`, such as `String`.
2. Get the name from the parameters. By default, this returns a `String`. If you want to extract another type, such as `Int` or `UUID` you can write `req.parameters.require("id", as: UUID.self)` and Vapor will attempt to cast it to the type and automatically throw an error if it's unable to. This throws an error if the route hasn't been registered with the correct parameter name.
Expand Down
10 changes: 5 additions & 5 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ atom: true
Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.

<div class="links links-list-nostyle" markdown="1">
- [Get started with Swift](/getting-started)
- [Read the documentation](/documentation)
- [Latest release: 5.7](/download/#swift-57)
- [Latest release: 5.7](/blog/swift-5.7-released)
- [Get started](/getting-started)
- [Read the docs](/documentation)
</div>

## Why Swift?
Expand Down Expand Up @@ -57,7 +57,7 @@ No matter how you want to get involved, we ask that you first learn what’s exp
Anyone with a good idea can help shape the future features and direction of the language. To reach the best possible solution to a problem, we discuss and iterate on ideas in a public forum.

<div class="links links-list-nostyle" markdown="1">
- [The Swift Evolution Process](/contributing/#participating-in-the-swift-evolution-process)
- [The Swift Evolution Process](/contributing/#swift-evolution)
</div>

### Code
Expand All @@ -84,4 +84,4 @@ Stay up-to-date with the latest in the Swift community.
- [Visit the Swift.org blog](/blog/)
- [Visit the Swift forums](https://forums.swift.org)
- [Follow @Swiftlang on Twitter](https://twitter.com/swiftlang){:target="_blank" class="link-external"}
</div>
</div>