March 2020
Intermediate to advanced
392 pages
10h 10m
English
A self-contained server is a program that does not need another program to run. A PHP script, for example, will run through at least two other programs: PHP (the compiler) and Nginx, Apache, or another HTTP(S) server. A self-contained server such as a Swift application, however, is the only application that needs to run; it answers HTTP(S) requests directly.
Let's look at a small Swift web server:
import Vaporlet app = try Application() app.get("hello") { req in return "Hello, world."} try app.run()
Without going into much detail, the crucial part is the last line:
try app.run()
The application does not close; it keeps running. What the framework (Vapor) and the network library (SwiftNIO) are hiding here is that the ...
Read now
Unlock full access