官术网_书友最值得收藏!

Building servers using Vapor's engine

Before we start using Vapor, let's see how the Vapor package is built on top of its engine package. This will give us a better understanding of what, exactly, Vapor provides, and what is provided by the dependencies that it consumes, in case you need to build a lightweight server or want to embrace building your own variation of a web framework. We will do the following:

  1. First, build a basic web server that returns Hello World
  2. Then, modify our Hello World server to serve file content, making a static file server similar to Apache or Nginx
  3. Lastly, we will build a web socket server that will accept connections and echo back the message sent via the web socket connection

Going through the exercise of building these different kinds of servers using Vapor's engine will help us understand how Vapor works under the hood. It will also help us realize that building a large scale web application requires a lot of features, such as routing, persisting to the database, migrations, rendering HTML templates, and much more, which Vapor provides via its other Swift packages. This makes Vapor very modular, and anyone who wants to build something lightweight can pick and choose the modules they want, or they can use the Vapor Swift package to get the entire bundle pre-configured, making it easy to build large-scale web applications quickly.

主站蜘蛛池模板: 广汉市| 巴林右旗| 商丘市| 望江县| 巴林左旗| 嘉兴市| 乌兰浩特市| 藁城市| 渭南市| 海门市| 安国市| 天气| 来宾市| 乌海市| 洪雅县| 白沙| 巴东县| 铜川市| 宜州市| 敖汉旗| 清河县| 怀集县| 霞浦县| 长寿区| 永城市| 永登县| 长岭县| 鄂托克前旗| 荣成市| 江陵县| 深圳市| 宁陵县| 景德镇市| 施秉县| 河东区| 榆林市| 临潭县| 嘉祥县| 全南县| 阳东县| 长宁县|