diff --git a/build/2.0/404.html b/build/2.0/404.html index 8350a2bc..82f2d716 100644 --- a/build/2.0/404.html +++ b/build/2.0/404.html @@ -1173,12 +1173,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/auth/getting-started/index.html b/build/2.0/auth/getting-started/index.html index cb627dfc..a8f789cd 100644 --- a/build/2.0/auth/getting-started/index.html +++ b/build/2.0/auth/getting-started/index.html @@ -1324,12 +1324,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/auth/helper/index.html b/build/2.0/auth/helper/index.html index d3356e7c..658ef4c7 100644 --- a/build/2.0/auth/helper/index.html +++ b/build/2.0/auth/helper/index.html @@ -1262,12 +1262,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/auth/package/index.html b/build/2.0/auth/package/index.html index 209f4aea..38bb7864 100644 --- a/build/2.0/auth/package/index.html +++ b/build/2.0/auth/package/index.html @@ -1222,12 +1222,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/auth/password/index.html b/build/2.0/auth/password/index.html index 39c8e582..f672de62 100644 --- a/build/2.0/auth/password/index.html +++ b/build/2.0/auth/password/index.html @@ -1242,12 +1242,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/auth/persist/index.html b/build/2.0/auth/persist/index.html index 2360db8b..cb0cc693 100644 --- a/build/2.0/auth/persist/index.html +++ b/build/2.0/auth/persist/index.html @@ -1283,12 +1283,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/auth/provider/index.html b/build/2.0/auth/provider/index.html index e24c3836..e16e56dc 100644 --- a/build/2.0/auth/provider/index.html +++ b/build/2.0/auth/provider/index.html @@ -1222,12 +1222,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/bits/overview/index.html b/build/2.0/bits/overview/index.html index 7446b964..6be00799 100644 --- a/build/2.0/bits/overview/index.html +++ b/build/2.0/bits/overview/index.html @@ -1179,12 +1179,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/bits/package/index.html b/build/2.0/bits/package/index.html index 230f0af4..e1765052 100644 --- a/build/2.0/bits/package/index.html +++ b/build/2.0/bits/package/index.html @@ -1179,12 +1179,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/cache/overview/index.html b/build/2.0/cache/overview/index.html index 3e81fee0..40e1a253 100644 --- a/build/2.0/cache/overview/index.html +++ b/build/2.0/cache/overview/index.html @@ -1262,12 +1262,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/cache/package/index.html b/build/2.0/cache/package/index.html index d8a7cee9..fed45682 100644 --- a/build/2.0/cache/package/index.html +++ b/build/2.0/cache/package/index.html @@ -1190,12 +1190,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/configs/config/index.html b/build/2.0/configs/config/index.html index 20d0bfe8..ee655cdb 100644 --- a/build/2.0/configs/config/index.html +++ b/build/2.0/configs/config/index.html @@ -1289,12 +1289,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/core/overview/index.html b/build/2.0/core/overview/index.html index 31b907c2..425d6d3b 100644 --- a/build/2.0/core/overview/index.html +++ b/build/2.0/core/overview/index.html @@ -1179,12 +1179,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/core/package/index.html b/build/2.0/core/package/index.html index 750201c9..2fa41257 100644 --- a/build/2.0/core/package/index.html +++ b/build/2.0/core/package/index.html @@ -1179,12 +1179,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/debugging/overview/index.html b/build/2.0/debugging/overview/index.html index 4b054aaf..244179c6 100644 --- a/build/2.0/debugging/overview/index.html +++ b/build/2.0/debugging/overview/index.html @@ -1179,12 +1179,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/debugging/package/index.html b/build/2.0/debugging/package/index.html index 3b89f117..5ff7fd89 100644 --- a/build/2.0/debugging/package/index.html +++ b/build/2.0/debugging/package/index.html @@ -1179,12 +1179,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/deploy/nginx/index.html b/build/2.0/deploy/nginx/index.html index e9136042..1c21d00d 100644 --- a/build/2.0/deploy/nginx/index.html +++ b/build/2.0/deploy/nginx/index.html @@ -1179,12 +1179,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/deploy/supervisor/index.html b/build/2.0/deploy/supervisor/index.html index 85955483..177badfb 100644 --- a/build/2.0/deploy/supervisor/index.html +++ b/build/2.0/deploy/supervisor/index.html @@ -1179,12 +1179,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/fluent/database/index.html b/build/2.0/fluent/database/index.html index 48ad124f..660236f3 100644 --- a/build/2.0/fluent/database/index.html +++ b/build/2.0/fluent/database/index.html @@ -1311,12 +1311,48 @@ -
  • - +
  • + + + + + +
  • + @@ -1844,8 +1880,8 @@ Adding a preparation to your model will allow you to prepare the database while -

    Once you have created you preparation, add it to the Droplet's prepratations array.

    -
    drop.preparations.append(User.self)
    +

    Once you have created you preparation, add it to the Config's prepratations array.

    +
    config.preparations.append(User.self)
     
    diff --git a/build/2.0/fluent/getting-started/index.html b/build/2.0/fluent/getting-started/index.html index 29454d2c..8f891a82 100644 --- a/build/2.0/fluent/getting-started/index.html +++ b/build/2.0/fluent/getting-started/index.html @@ -1323,12 +1323,48 @@ -
  • - +
  • + + + + + +
  • + @@ -1795,12 +1831,22 @@ var age: Int let storage = Storage() + init(row: Row) throws { + name = try row.get("name") + age = try row.get("age") + } + init(name: String, age: Int) { self.name = name self.age = age } - ... + func makeRow() throws -> Row { + var row = Row() + try row.set("name", name) + try row.set("age", age) + return row + } }
    @@ -1845,7 +1891,7 @@
    extension Pet: Preparation {
         static func prepare(_ database: Database) throws {
             try database.create(self) { pets in
    -            pets.id(for: self)
    +            pets.id()
                 pets.string("name")
                 pets.int("age")
             }
    @@ -1876,13 +1922,13 @@
     
     
     

    Add to Droplet

    -

    Now you can add your model to the Droplet's prearations so the database is prepared when your application boots.

    +

    Now you can add your model to the config's prearations so the database is prepared when your application boots.

    import Vapor
     import FluentProvider
     
    -let drop = try Droplet()
    -
    -drop.preparations.append(Pet.self)
    +let config = try Config()
    +config.preparations.append(Pet.self)
    +let drop = try Droplet(config)
     
     ...
     
    diff --git a/build/2.0/fluent/model/index.html b/build/2.0/fluent/model/index.html index aa46f714..bbfb0302 100644 --- a/build/2.0/fluent/model/index.html +++ b/build/2.0/fluent/model/index.html @@ -1406,12 +1406,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/fluent/package/index.html b/build/2.0/fluent/package/index.html index 0c72fe1f..f6f12fff 100644 --- a/build/2.0/fluent/package/index.html +++ b/build/2.0/fluent/package/index.html @@ -1229,12 +1229,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/fluent/query/index.html b/build/2.0/fluent/query/index.html index c608a275..f3cec2ee 100644 --- a/build/2.0/fluent/query/index.html +++ b/build/2.0/fluent/query/index.html @@ -1331,12 +1331,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/fluent/relations/index.html b/build/2.0/fluent/relations/index.html index cac8380c..048704f9 100644 --- a/build/2.0/fluent/relations/index.html +++ b/build/2.0/fluent/relations/index.html @@ -1316,12 +1316,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/getting-started/hello-world/index.html b/build/2.0/getting-started/hello-world/index.html index 9463c178..9d2e283d 100644 --- a/build/2.0/getting-started/hello-world/index.html +++ b/build/2.0/getting-started/hello-world/index.html @@ -1302,12 +1302,48 @@ -
  • - +
  • + + + + + +
  • + @@ -1799,14 +1835,14 @@

    Code

    Droplet

    Look for the following line in the Routes.swift file.

    -
    func build(_ builder: RouteBuilder) throws
    +
    func setupRoutes() throws
     

    This method is where all the routes for our application will be added.

    Routing

    In the scope of the build method, look for the following statement.

    -
    builder.get("plaintext") { req in
    +
    get("plaintext") { req in
         return "Hello, world!"
     }
     
    @@ -1881,7 +1917,7 @@

    Warning

    If you compiled your application with --release, make sure to add that flag to the vapor run command as well. e.g., vapor run serve --env=production --release.

    -

    For more information on deploying your code, check out the deploy section.

    +

    For more information on deploying your code, check out the deploy section.

    diff --git a/build/2.0/getting-started/install-on-macos/index.html b/build/2.0/getting-started/install-on-macos/index.html index 3170ee30..8181517c 100644 --- a/build/2.0/getting-started/install-on-macos/index.html +++ b/build/2.0/getting-started/install-on-macos/index.html @@ -1283,12 +1283,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/getting-started/install-on-ubuntu/index.html b/build/2.0/getting-started/install-on-ubuntu/index.html index c8d2ebe0..1f573bc9 100644 --- a/build/2.0/getting-started/install-on-ubuntu/index.html +++ b/build/2.0/getting-started/install-on-ubuntu/index.html @@ -1270,12 +1270,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/getting-started/manual/index.html b/build/2.0/getting-started/manual/index.html index 22fab947..d8edcf9e 100644 --- a/build/2.0/getting-started/manual/index.html +++ b/build/2.0/getting-started/manual/index.html @@ -1256,12 +1256,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/getting-started/toolbox/index.html b/build/2.0/getting-started/toolbox/index.html index 1180c7d9..5d557f7e 100644 --- a/build/2.0/getting-started/toolbox/index.html +++ b/build/2.0/getting-started/toolbox/index.html @@ -1262,12 +1262,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/getting-started/xcode/index.html b/build/2.0/getting-started/xcode/index.html index 692ae8d9..e3c6539b 100644 --- a/build/2.0/getting-started/xcode/index.html +++ b/build/2.0/getting-started/xcode/index.html @@ -303,6 +303,13 @@
    diff --git a/build/2.0/http/cors/index.html b/build/2.0/http/cors/index.html index 90fc9411..77759163 100644 --- a/build/2.0/http/cors/index.html +++ b/build/2.0/http/cors/index.html @@ -1235,12 +1235,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/http/middleware/index.html b/build/2.0/http/middleware/index.html index 6eda4fb9..9fb53168 100644 --- a/build/2.0/http/middleware/index.html +++ b/build/2.0/http/middleware/index.html @@ -1310,12 +1310,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/http/package/index.html b/build/2.0/http/package/index.html index a3ae67e2..a0d6822a 100644 --- a/build/2.0/http/package/index.html +++ b/build/2.0/http/package/index.html @@ -1222,12 +1222,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/http/request/index.html b/build/2.0/http/request/index.html index 37f63fad..8414a375 100644 --- a/build/2.0/http/request/index.html +++ b/build/2.0/http/request/index.html @@ -1325,12 +1325,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/http/responder/index.html b/build/2.0/http/responder/index.html index ab1222fe..90c3b74d 100644 --- a/build/2.0/http/responder/index.html +++ b/build/2.0/http/responder/index.html @@ -1236,12 +1236,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/http/response-representable/index.html b/build/2.0/http/response-representable/index.html index acd3bb64..41a182be 100644 --- a/build/2.0/http/response-representable/index.html +++ b/build/2.0/http/response-representable/index.html @@ -1236,12 +1236,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/http/response/index.html b/build/2.0/http/response/index.html index 7dcf077f..260b203c 100644 --- a/build/2.0/http/response/index.html +++ b/build/2.0/http/response/index.html @@ -1290,12 +1290,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/http/server/index.html b/build/2.0/http/server/index.html index abde46a9..45390808 100644 --- a/build/2.0/http/server/index.html +++ b/build/2.0/http/server/index.html @@ -1331,12 +1331,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/index.html b/build/2.0/index.html index 7705f199..1bee2193 100644 --- a/build/2.0/index.html +++ b/build/2.0/index.html @@ -1331,12 +1331,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/json/overview/index.html b/build/2.0/json/overview/index.html index fdf5f705..7bd9f1ef 100644 --- a/build/2.0/json/overview/index.html +++ b/build/2.0/json/overview/index.html @@ -1262,12 +1262,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/json/package/index.html b/build/2.0/json/package/index.html index efce4b1e..baea5eb4 100644 --- a/build/2.0/json/package/index.html +++ b/build/2.0/json/package/index.html @@ -1222,12 +1222,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/leaf/leaf/index.html b/build/2.0/leaf/leaf/index.html index 5e967892..9f5f0cb2 100644 --- a/build/2.0/leaf/leaf/index.html +++ b/build/2.0/leaf/leaf/index.html @@ -1387,12 +1387,48 @@ -
  • - +
  • + + + + + +
  • + @@ -2094,13 +2130,13 @@ Hello, #index(friends, "best")! -
  • +
  • + + + + + +
  • + diff --git a/build/2.0/leaf/provider/index.html b/build/2.0/leaf/provider/index.html index 1ca931f3..825740a7 100644 --- a/build/2.0/leaf/provider/index.html +++ b/build/2.0/leaf/provider/index.html @@ -1236,12 +1236,48 @@ -
  • - +
  • + + + + + +
  • + @@ -1642,9 +1678,8 @@
    import Vapor
     import LeafProvider
     
    -let drop = try Droplet()
    -
    -drop.view = LeafRenderer(viewsDir: drop.viewsDir)
    +let view = LeafRenderer(viewsDir: drop.viewsDir)
    +let drop = try Droplet(view: view)
     
    diff --git a/build/2.0/mkdocs/search_index.json b/build/2.0/mkdocs/search_index.json index 7d2cf7ca..209aa66e 100644 --- a/build/2.0/mkdocs/search_index.json +++ b/build/2.0/mkdocs/search_index.json @@ -232,7 +232,7 @@ }, { "location": "/getting-started/hello-world/", - "text": "Hello, World\n\n\nThis section assumes you have installed Swift 3.1 and the Vapor Toolbox and have verified they are working.\n\n\n\n\nTip\n\n\nNote: If you don't want to use the Toolbox, follow the \nmanual guide\n.\n\n\n\n\nNew Project\n\n\nLet's start by creating a new project called \"Hello, World\".\n\n\nvapor new Hello --template\n=\napi\n\n\n\n\n\nVapor's folder structure will probably look familiar to you if you have worked with other web frameworks.\n\n\nHello\n\u251c\u2500\u2500 Config\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 app.json\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 crypto.json\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 droplet.json\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 fluent.json\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 server.json\n\u251c\u2500\u2500 Package.pins\n\u251c\u2500\u2500 Package.swift\n\u251c\u2500\u2500 Public\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 Sources\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 App\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Config+Setup.swift\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Controllers\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 PostController.swift\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Droplet+Setup.swift\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Models\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 Post.swift\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 Routes.swift\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 Run\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 main.swift\n\u251c\u2500\u2500 Tests\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 AppTests\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 PostControllerTests.swift\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 RouteTests.swift\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 Utilities.swift\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 LinuxMain.swift\n\u251c\u2500\u2500 circle.yml\n\u2514\u2500\u2500 license\n\n\n\n\n\nFor our Hello, World project, we will be focusing on the \nRoutes.swift\n file.\n\n\nHello\n\u2514\u2500\u2500 Sources\n \u2514\u2500\u2500 App\n \u2514\u2500\u2500 Routes.swift\n\n\n\n\n\n\n\nTip\n\n\nThe \nvapor new\n command creates a new project with examples and comments about how to use the framework. You can delete these if you want.\n\n\n\n\nCode\n\n\nDroplet\n\n\nLook for the following line in the \nRoutes.swift\n file.\n\n\nfunc\n \nbuild\n(\n_\n \nbuilder\n:\n \nRouteBuilder\n)\n \nthrows\n\n\n\n\n\n\nThis method is where all the routes for our application will be added. \n\n\nRouting\n\n\nIn the scope of the \nbuild\n method, look for the following statement.\n\n\nbuilder\n.\nget\n(\nplaintext\n)\n \n{\n \nreq\n \nin\n\n \nreturn\n \nHello, world!\n\n\n}\n\n\n\n\n\n\nThis creates a new route that will match all \nGET\n requests to \n/plaintext\n.\n\n\nAll route closures are passed an instance of \nRequest\n that contains information such as the URI requested and data sent.\n\n\nThis route simply returns a string, but anything that is \nResponseRepresentable\n can be returned. Learn more in the \nRouting\n section of the guide.\n\n\n\n\nTip\n\n\nXcode autocomplete may add extraneous type information to your closure's input arguments. This can be deleted to keep the code clean. If you'd like to keep the type information add \nimport HTTP\n to the top of the file.\n\n\n\n\nCompile \n Run\n\n\nBuilding\n\n\nA big part of what makes Vapor so great is Swift's state of the art compiler. Let's fire it up. Make sure you are in the root directory of the project and run the following command.\n\n\nvapor\n \nbuild\n\n\n\n\n\n\n\n\nNote\n\n\nvapor build\n runs \nswift build\n in the background.\n\n\n\n\nThe Swift Package Manager will first start by downloading the appropriate dependencies from git. It will then compile and link these dependencies together.\n\n\nWhen the process has completed, you will see \nBuilding Project [Done]\n\n\n\n\nTip\n\n\nIf you see a message like \nunable to execute command: Killed\n, you need to increase your swap space. This can happen if you are running on a machine with limited memory.\n\n\n\n\nRelease\n\n\nBuilding your application in release mode takes longer, but increases performance.\n\n\nvapor build --release\n\n\n\n\n\nServing\n\n\nBoot up the server by running the following command.\n\n\nvapor run serve\n\n\n\n\n\nYou should see a message \nServer starting...\n. \n\n\nYou can now visit \nlocalhost:8080/plaintext\n in your browser or run \n\n\ncurl localhost:8080/plaintext\n\n\n\n\n\n\n\nNote\n\n\nCertain port numbers require super user access to bind. Simply run \nsudo vapor run\n to allow access. If you decide to run on a port besides \n80\n, make sure to direct your browser accordingly.\n\n\n\n\nHello, World\n\n\nYou should see the following output in your browser window.\n\n\nHello, world!\n\n\n\n\n\n\n\nSuccess\n\n\nLike Vapor so far? Click the button below and star the repo to help spread the word! \n\n\n\n\n\n\n\nProduction\n\n\nServing your application in the production environment increases its security and performance.\n\n\nvapor run serve --env\n=\nproduction\n\n\n\n\n\nSome debug messages will be silenced while in the production environment, so make sure to check your logs for errors.\n\n\n\n\nWarning\n\n\nIf you compiled your application with \n--release\n, make sure to add that flag to the \nvapor run\n command as well. e.g., \nvapor run serve --env=production --release\n.\n\n\n\n\nFor more information on deploying your code, check out the \ndeploy section\n.", + "text": "Hello, World\n\n\nThis section assumes you have installed Swift 3.1 and the Vapor Toolbox and have verified they are working.\n\n\n\n\nTip\n\n\nNote: If you don't want to use the Toolbox, follow the \nmanual guide\n.\n\n\n\n\nNew Project\n\n\nLet's start by creating a new project called \"Hello, World\".\n\n\nvapor new Hello --template\n=\napi\n\n\n\n\n\nVapor's folder structure will probably look familiar to you if you have worked with other web frameworks.\n\n\nHello\n\u251c\u2500\u2500 Config\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 app.json\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 crypto.json\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 droplet.json\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 fluent.json\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 server.json\n\u251c\u2500\u2500 Package.pins\n\u251c\u2500\u2500 Package.swift\n\u251c\u2500\u2500 Public\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 Sources\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 App\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Config+Setup.swift\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Controllers\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 PostController.swift\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Droplet+Setup.swift\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Models\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 Post.swift\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 Routes.swift\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 Run\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 main.swift\n\u251c\u2500\u2500 Tests\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 AppTests\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 PostControllerTests.swift\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 RouteTests.swift\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 Utilities.swift\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 LinuxMain.swift\n\u251c\u2500\u2500 circle.yml\n\u2514\u2500\u2500 license\n\n\n\n\n\nFor our Hello, World project, we will be focusing on the \nRoutes.swift\n file.\n\n\nHello\n\u2514\u2500\u2500 Sources\n \u2514\u2500\u2500 App\n \u2514\u2500\u2500 Routes.swift\n\n\n\n\n\n\n\nTip\n\n\nThe \nvapor new\n command creates a new project with examples and comments about how to use the framework. You can delete these if you want.\n\n\n\n\nCode\n\n\nDroplet\n\n\nLook for the following line in the \nRoutes.swift\n file.\n\n\nfunc\n \nsetupRoutes\n()\n \nthrows\n\n\n\n\n\n\nThis method is where all the routes for our application will be added. \n\n\nRouting\n\n\nIn the scope of the \nbuild\n method, look for the following statement.\n\n\nget\n(\nplaintext\n)\n \n{\n \nreq\n \nin\n\n \nreturn\n \nHello, world!\n\n\n}\n\n\n\n\n\n\nThis creates a new route that will match all \nGET\n requests to \n/plaintext\n.\n\n\nAll route closures are passed an instance of \nRequest\n that contains information such as the URI requested and data sent.\n\n\nThis route simply returns a string, but anything that is \nResponseRepresentable\n can be returned. Learn more in the \nRouting\n section of the guide.\n\n\n\n\nTip\n\n\nXcode autocomplete may add extraneous type information to your closure's input arguments. This can be deleted to keep the code clean. If you'd like to keep the type information add \nimport HTTP\n to the top of the file.\n\n\n\n\nCompile \n Run\n\n\nBuilding\n\n\nA big part of what makes Vapor so great is Swift's state of the art compiler. Let's fire it up. Make sure you are in the root directory of the project and run the following command.\n\n\nvapor\n \nbuild\n\n\n\n\n\n\n\n\nNote\n\n\nvapor build\n runs \nswift build\n in the background.\n\n\n\n\nThe Swift Package Manager will first start by downloading the appropriate dependencies from git. It will then compile and link these dependencies together.\n\n\nWhen the process has completed, you will see \nBuilding Project [Done]\n\n\n\n\nTip\n\n\nIf you see a message like \nunable to execute command: Killed\n, you need to increase your swap space. This can happen if you are running on a machine with limited memory.\n\n\n\n\nRelease\n\n\nBuilding your application in release mode takes longer, but increases performance.\n\n\nvapor build --release\n\n\n\n\n\nServing\n\n\nBoot up the server by running the following command.\n\n\nvapor run serve\n\n\n\n\n\nYou should see a message \nServer starting...\n. \n\n\nYou can now visit \nlocalhost:8080/plaintext\n in your browser or run \n\n\ncurl localhost:8080/plaintext\n\n\n\n\n\n\n\nNote\n\n\nCertain port numbers require super user access to bind. Simply run \nsudo vapor run\n to allow access. If you decide to run on a port besides \n80\n, make sure to direct your browser accordingly.\n\n\n\n\nHello, World\n\n\nYou should see the following output in your browser window.\n\n\nHello, world!\n\n\n\n\n\n\n\nSuccess\n\n\nLike Vapor so far? Click the button below and star the repo to help spread the word! \n\n\n\n\n\n\n\nProduction\n\n\nServing your application in the production environment increases its security and performance.\n\n\nvapor run serve --env\n=\nproduction\n\n\n\n\n\nSome debug messages will be silenced while in the production environment, so make sure to check your logs for errors.\n\n\n\n\nWarning\n\n\nIf you compiled your application with \n--release\n, make sure to add that flag to the \nvapor run\n command as well. e.g., \nvapor run serve --env=production --release\n.\n\n\n\n\nFor more information on deploying your code, check out the \ndeploy section\n.", "title": "Hello, World" }, { @@ -252,12 +252,12 @@ }, { "location": "/getting-started/hello-world/#droplet", - "text": "Look for the following line in the Routes.swift file. func build ( _ builder : RouteBuilder ) throws This method is where all the routes for our application will be added.", + "text": "Look for the following line in the Routes.swift file. func setupRoutes () throws This method is where all the routes for our application will be added.", "title": "Droplet" }, { "location": "/getting-started/hello-world/#routing", - "text": "In the scope of the build method, look for the following statement. builder . get ( plaintext ) { req in \n return Hello, world! } This creates a new route that will match all GET requests to /plaintext . All route closures are passed an instance of Request that contains information such as the URI requested and data sent. This route simply returns a string, but anything that is ResponseRepresentable can be returned. Learn more in the Routing section of the guide. Tip Xcode autocomplete may add extraneous type information to your closure's input arguments. This can be deleted to keep the code clean. If you'd like to keep the type information add import HTTP to the top of the file.", + "text": "In the scope of the build method, look for the following statement. get ( plaintext ) { req in \n return Hello, world! } This creates a new route that will match all GET requests to /plaintext . All route closures are passed an instance of Request that contains information such as the URI requested and data sent. This route simply returns a string, but anything that is ResponseRepresentable can be returned. Learn more in the Routing section of the guide. Tip Xcode autocomplete may add extraneous type information to your closure's input arguments. This can be deleted to keep the code clean. If you'd like to keep the type information add import HTTP to the top of the file.", "title": "Routing" }, { @@ -332,7 +332,7 @@ }, { "location": "/getting-started/xcode/", - "text": "Xcode\n\n\nIf you're on a Mac, you can develop your Vapor project using Xcode. \nYou can build, run, and stop your server from within Xcode, as well as use breakpoints to debug your code.\n\n\n\n\nTo use Xcode, you will first need to generate a \n*.xcodeproj\n file.\n\n\nGenerate Project\n\n\nVapor Toolbox\n\n\nTo generate a new Xcode project for a project, use:\n\n\nvapor xcode\n\n\n\n\n\n\n\nTip\n\n\nIf you'd like to automatically open the Xcode project, use \nvapor xcode -y\n\n\n\n\nManual\n\n\nTo generate a new Xcode project manually.\n\n\nswift package generate-xcodeproj\n\n\n\n\n\nOpen the project and continue normally.", + "text": "Xcode\n\n\nIf you're on a Mac, you can develop your Vapor project using Xcode. \nYou can build, run, and stop your server from within Xcode, as well as use breakpoints to debug your code.\n\n\n\n\nTo use Xcode, you will first need to generate a \n*.xcodeproj\n file.\n\n\nSelect 'Run'\n\n\nMake sure after generating your Xcode project that you properly select the executable if you're trying to run your application.\n\n\n\n\nGenerate Project\n\n\nVapor Toolbox\n\n\nTo generate a new Xcode project for a project, use:\n\n\nvapor xcode\n\n\n\n\n\n\n\nTip\n\n\nIf you'd like to automatically open the Xcode project, use \nvapor xcode -y\n\n\n\n\nManual\n\n\nTo generate a new Xcode project manually.\n\n\nswift package generate-xcodeproj\n\n\n\n\n\nOpen the project and continue normally.", "title": "Xcode" }, { @@ -340,6 +340,11 @@ "text": "If you're on a Mac, you can develop your Vapor project using Xcode. \nYou can build, run, and stop your server from within Xcode, as well as use breakpoints to debug your code. To use Xcode, you will first need to generate a *.xcodeproj file.", "title": "Xcode" }, + { + "location": "/getting-started/xcode/#select-run", + "text": "Make sure after generating your Xcode project that you properly select the executable if you're trying to run your application.", + "title": "Select 'Run'" + }, { "location": "/getting-started/xcode/#generate-project", "text": "", @@ -997,7 +1002,7 @@ }, { "location": "/fluent/getting-started/", - "text": "Getting Started with Fluent\n\n\nFluent provides an easy, simple, and safe API for working with your persisted data. Each database table/collection is represented by a \nModel\n that can be used to interact with the data. Fluent supports common operations like creating, reading, updating, and deleting models. It also supports more advanced operations like joining, relating, and soft deleting. \n\n\n\n\nNote\n\n\nDon't forget to add \nimport FluentProvider\n (or your other database provider) to the top of your Swift files.\n\n\n\n\nFluent ships with SQLite by default. You can use SQLite to quickly scaffolding your application with the in-memory database it provides. This is enabled by default in Vapor's default template. To learn more about configuring your database, check out the available \ndrivers\n.\n\n\nCreating a Model\n\n\nModels are the Swift representations of the data in your database. As such, they are central to most of Fluent's APIs.\n\n\nLet's take a look at what a simple model looks like.\n\n\nfinal\n \nclass\n \nPet\n:\n \nModel\n \n{\n\n \nvar\n \nname\n:\n \nString\n\n \nvar\n \nage\n:\n \nInt\n\n \nlet\n \nstorage\n \n=\n \nStorage\n()\n\n\n \ninit\n(\nname\n:\n \nString\n,\n \nage\n:\n \nInt\n)\n \n{\n\n \nself\n.\nname\n \n=\n \nname\n\n \nself\n.\nage\n \n=\n \nage\n\n \n}\n\n\n \n...\n\n\n}\n\n\n\n\n\n\nHere we are creating a simple class \nPet\n with a name and an age. We will add a simple init method for creating new pets.\n\n\nStorage\n\n\nThe \nstorage\n property is there to allow Fluent to store extra information on your model--things like the model's database id. \n\n\nRow\n\n\nThe \nRow\n struct represents a database row. Your models should be able to parse from and serialize to database rows.\n\n\nParse\n\n\nHere's the code for parsing the Pet from the database.\n\n\nfinal\n \nclass\n \nPet\n:\n \nModel\n \n{\n\n \n...\n\n\n \ninit\n(\nrow\n:\n \nRow\n)\n \nthrows\n \n{\n\n \nname\n \n=\n \ntry\n \nrow\n.\nget\n(\nname\n)\n\n \nage\n \n=\n \ntry\n \nrow\n.\nget\n(\nage\n)\n\n \n}\n\n\n}\n\n\n\n\n\n\nSerialize\n\n\nHere's the code for serializing the Pet to the database.\n\n\nfinal\n \nclass\n \nPet\n:\n \nModel\n \n{\n\n \n...\n\n\n \nfunc\n \nmakeRow\n()\n \nthrows\n \n-\n \nRow\n \n{\n\n \nvar\n \nrow\n \n=\n \nRow\n()\n\n \ntry\n \nrow\n.\nset\n(\nname\n,\n \nname\n)\n\n \ntry\n \nrow\n.\nset\n(\nage\n,\n \nage\n)\n\n \nreturn\n \nrow\n\n \n}\n\n\n}\n\n\n\n\n\n\nPreparing the Database\n\n\nIn order to use your model, you may need to prepare your database with an appropriate schema.\n\n\nPreparation\n\n\nYou can do this by conforming your model to \nPreparation\n.\n\n\nextension\n \nPet\n:\n \nPreparation\n \n{\n\n \nstatic\n \nfunc\n \nprepare\n(\n_\n \ndatabase\n:\n \nDatabase\n)\n \nthrows\n \n{\n\n \ntry\n \ndatabase\n.\ncreate\n(\nself\n)\n \n{\n \npets\n \nin\n\n \npets\n.\nid\n(\nfor\n:\n \nself\n)\n\n \npets\n.\nstring\n(\nname\n)\n\n \npets\n.\nint\n(\nage\n)\n\n \n}\n\n \n}\n \n\n \nstatic\n \nfunc\n \nrevert\n(\n_\n \ndatabase\n:\n \nDatabase\n)\n \nthrows\n \n{\n\n \ntry\n \ndatabase\n.\ndelete\n(\nself\n)\n\n \n}\n\n\n}\n\n\n\n\n\n\nHere we are creating a simple table that will look like this:\n\n\n\n\n\n\n\n\nid\n\n\nname\n\n\nage\n\n\n\n\n\n\n\n\n\n\ndatabase id type\n\n\nstring\n\n\nint\n\n\n\n\n\n\n\n\nAdd to Droplet\n\n\nNow you can add your model to the Droplet's prearations so the database is prepared when your application boots.\n\n\nimport\n \nVapor\n\n\nimport\n \nFluentProvider\n\n\n\nlet\n \ndrop\n \n=\n \ntry\n \nDroplet\n()\n\n\n\ndrop\n.\npreparations\n.\nappend\n(\nPet\n.\nself\n)\n\n\n\n...\n\n\n\n\n\n\nUsing Models\n\n\nNow that we have created our model and prepared the database, we can use it to save and fetch data from the database.\n\n\nSave\n\n\nTo save a model, call \n.save()\n. A new identifier for the model will automatically be created.\n\n\nlet\n \ndog\n \n=\n \nPet\n(\nname\n:\n \nSpud\n,\n \nage\n:\n \n5\n)\n\n\ntry\n \ndog\n.\nsave\n()\n\n\nprint\n(\ndog\n.\nid\n)\n \n// the newly saved pet\ns id\n\n\n\n\n\n\nFind\n\n\nYou can fetch a model from the database using it's ID.\n\n\nguard\n \nlet\n \ndog\n \n=\n \ntry\n \nPet\n.\nfind\n(\n42\n)\n \nelse\n \n{\n\n \nthrow\n \nAbort\n.\nnotFound\n\n\n}\n\n\n\nprint\n(\ndog\n.\nname\n)\n \n// the name of the dog with id 42\n\n\n\n\n\n\nFilter\n\n\nYou can also search for models using filters.\n\n\nlet\n \ndogs\n \n=\n \ntry\n \nPet\n.\nmakeQuery\n().\nfilter\n(\nage\n,\n \n.\ngreaterThan\n,\n \n2\n).\nall\n()\n\n\nprint\n(\ndogs\n)\n \n// all dogs older than 2\n\n\n\n\n\n\nDrivers\n\n\nCheck out the \ndatabase\n section for more information about different database drivers you can use with Fluent.", + "text": "Getting Started with Fluent\n\n\nFluent provides an easy, simple, and safe API for working with your persisted data. Each database table/collection is represented by a \nModel\n that can be used to interact with the data. Fluent supports common operations like creating, reading, updating, and deleting models. It also supports more advanced operations like joining, relating, and soft deleting. \n\n\n\n\nNote\n\n\nDon't forget to add \nimport FluentProvider\n (or your other database provider) to the top of your Swift files.\n\n\n\n\nFluent ships with SQLite by default. You can use SQLite to quickly scaffolding your application with the in-memory database it provides. This is enabled by default in Vapor's default template. To learn more about configuring your database, check out the available \ndrivers\n.\n\n\nCreating a Model\n\n\nModels are the Swift representations of the data in your database. As such, they are central to most of Fluent's APIs.\n\n\nLet's take a look at what a simple model looks like.\n\n\nfinal\n \nclass\n \nPet\n:\n \nModel\n \n{\n\n \nvar\n \nname\n:\n \nString\n\n \nvar\n \nage\n:\n \nInt\n\n \nlet\n \nstorage\n \n=\n \nStorage\n()\n\n\n \ninit\n(\nrow\n:\n \nRow\n)\n \nthrows\n \n{\n\n \nname\n \n=\n \ntry\n \nrow\n.\nget\n(\nname\n)\n\n \nage\n \n=\n \ntry\n \nrow\n.\nget\n(\nage\n)\n\n \n}\n\n\n \ninit\n(\nname\n:\n \nString\n,\n \nage\n:\n \nInt\n)\n \n{\n\n \nself\n.\nname\n \n=\n \nname\n\n \nself\n.\nage\n \n=\n \nage\n\n \n}\n\n\n \nfunc\n \nmakeRow\n()\n \nthrows\n \n-\n \nRow\n \n{\n\n \nvar\n \nrow\n \n=\n \nRow\n()\n\n \ntry\n \nrow\n.\nset\n(\nname\n,\n \nname\n)\n\n \ntry\n \nrow\n.\nset\n(\nage\n,\n \nage\n)\n\n \nreturn\n \nrow\n\n \n}\n\n\n}\n\n\n\n\n\n\nHere we are creating a simple class \nPet\n with a name and an age. We will add a simple init method for creating new pets.\n\n\nStorage\n\n\nThe \nstorage\n property is there to allow Fluent to store extra information on your model--things like the model's database id. \n\n\nRow\n\n\nThe \nRow\n struct represents a database row. Your models should be able to parse from and serialize to database rows.\n\n\nParse\n\n\nHere's the code for parsing the Pet from the database.\n\n\nfinal\n \nclass\n \nPet\n:\n \nModel\n \n{\n\n \n...\n\n\n \ninit\n(\nrow\n:\n \nRow\n)\n \nthrows\n \n{\n\n \nname\n \n=\n \ntry\n \nrow\n.\nget\n(\nname\n)\n\n \nage\n \n=\n \ntry\n \nrow\n.\nget\n(\nage\n)\n\n \n}\n\n\n}\n\n\n\n\n\n\nSerialize\n\n\nHere's the code for serializing the Pet to the database.\n\n\nfinal\n \nclass\n \nPet\n:\n \nModel\n \n{\n\n \n...\n\n\n \nfunc\n \nmakeRow\n()\n \nthrows\n \n-\n \nRow\n \n{\n\n \nvar\n \nrow\n \n=\n \nRow\n()\n\n \ntry\n \nrow\n.\nset\n(\nname\n,\n \nname\n)\n\n \ntry\n \nrow\n.\nset\n(\nage\n,\n \nage\n)\n\n \nreturn\n \nrow\n\n \n}\n\n\n}\n\n\n\n\n\n\nPreparing the Database\n\n\nIn order to use your model, you may need to prepare your database with an appropriate schema.\n\n\nPreparation\n\n\nYou can do this by conforming your model to \nPreparation\n.\n\n\nextension\n \nPet\n:\n \nPreparation\n \n{\n\n \nstatic\n \nfunc\n \nprepare\n(\n_\n \ndatabase\n:\n \nDatabase\n)\n \nthrows\n \n{\n\n \ntry\n \ndatabase\n.\ncreate\n(\nself\n)\n \n{\n \npets\n \nin\n\n \npets\n.\nid\n()\n\n \npets\n.\nstring\n(\nname\n)\n\n \npets\n.\nint\n(\nage\n)\n\n \n}\n\n \n}\n \n\n \nstatic\n \nfunc\n \nrevert\n(\n_\n \ndatabase\n:\n \nDatabase\n)\n \nthrows\n \n{\n\n \ntry\n \ndatabase\n.\ndelete\n(\nself\n)\n\n \n}\n\n\n}\n\n\n\n\n\n\nHere we are creating a simple table that will look like this:\n\n\n\n\n\n\n\n\nid\n\n\nname\n\n\nage\n\n\n\n\n\n\n\n\n\n\ndatabase id type\n\n\nstring\n\n\nint\n\n\n\n\n\n\n\n\nAdd to Droplet\n\n\nNow you can add your model to the config's prearations so the database is prepared when your application boots.\n\n\nimport\n \nVapor\n\n\nimport\n \nFluentProvider\n\n\n\nlet\n \nconfig\n \n=\n \ntry\n \nConfig\n()\n\n\nconfig\n.\npreparations\n.\nappend\n(\nPet\n.\nself\n)\n\n\nlet\n \ndrop\n \n=\n \ntry\n \nDroplet\n(\nconfig\n)\n\n\n\n...\n\n\n\n\n\n\nUsing Models\n\n\nNow that we have created our model and prepared the database, we can use it to save and fetch data from the database.\n\n\nSave\n\n\nTo save a model, call \n.save()\n. A new identifier for the model will automatically be created.\n\n\nlet\n \ndog\n \n=\n \nPet\n(\nname\n:\n \nSpud\n,\n \nage\n:\n \n5\n)\n\n\ntry\n \ndog\n.\nsave\n()\n\n\nprint\n(\ndog\n.\nid\n)\n \n// the newly saved pet\ns id\n\n\n\n\n\n\nFind\n\n\nYou can fetch a model from the database using it's ID.\n\n\nguard\n \nlet\n \ndog\n \n=\n \ntry\n \nPet\n.\nfind\n(\n42\n)\n \nelse\n \n{\n\n \nthrow\n \nAbort\n.\nnotFound\n\n\n}\n\n\n\nprint\n(\ndog\n.\nname\n)\n \n// the name of the dog with id 42\n\n\n\n\n\n\nFilter\n\n\nYou can also search for models using filters.\n\n\nlet\n \ndogs\n \n=\n \ntry\n \nPet\n.\nmakeQuery\n().\nfilter\n(\nage\n,\n \n.\ngreaterThan\n,\n \n2\n).\nall\n()\n\n\nprint\n(\ndogs\n)\n \n// all dogs older than 2\n\n\n\n\n\n\nDrivers\n\n\nCheck out the \ndatabase\n section for more information about different database drivers you can use with Fluent.", "title": "Getting Started" }, { @@ -1007,7 +1012,7 @@ }, { "location": "/fluent/getting-started/#creating-a-model", - "text": "Models are the Swift representations of the data in your database. As such, they are central to most of Fluent's APIs. Let's take a look at what a simple model looks like. final class Pet : Model { \n var name : String \n var age : Int \n let storage = Storage () \n\n init ( name : String , age : Int ) { \n self . name = name \n self . age = age \n } \n\n ... } Here we are creating a simple class Pet with a name and an age. We will add a simple init method for creating new pets.", + "text": "Models are the Swift representations of the data in your database. As such, they are central to most of Fluent's APIs. Let's take a look at what a simple model looks like. final class Pet : Model { \n var name : String \n var age : Int \n let storage = Storage () \n\n init ( row : Row ) throws { \n name = try row . get ( name ) \n age = try row . get ( age ) \n } \n\n init ( name : String , age : Int ) { \n self . name = name \n self . age = age \n } \n\n func makeRow () throws - Row { \n var row = Row () \n try row . set ( name , name ) \n try row . set ( age , age ) \n return row \n } } Here we are creating a simple class Pet with a name and an age. We will add a simple init method for creating new pets.", "title": "Creating a Model" }, { @@ -1037,12 +1042,12 @@ }, { "location": "/fluent/getting-started/#preparation", - "text": "You can do this by conforming your model to Preparation . extension Pet : Preparation { \n static func prepare ( _ database : Database ) throws { \n try database . create ( self ) { pets in \n pets . id ( for : self ) \n pets . string ( name ) \n pets . int ( age ) \n } \n } \n\n static func revert ( _ database : Database ) throws { \n try database . delete ( self ) \n } } Here we are creating a simple table that will look like this: id name age database id type string int", + "text": "You can do this by conforming your model to Preparation . extension Pet : Preparation { \n static func prepare ( _ database : Database ) throws { \n try database . create ( self ) { pets in \n pets . id () \n pets . string ( name ) \n pets . int ( age ) \n } \n } \n\n static func revert ( _ database : Database ) throws { \n try database . delete ( self ) \n } } Here we are creating a simple table that will look like this: id name age database id type string int", "title": "Preparation" }, { "location": "/fluent/getting-started/#add-to-droplet", - "text": "Now you can add your model to the Droplet's prearations so the database is prepared when your application boots. import Vapor import FluentProvider let drop = try Droplet () drop . preparations . append ( Pet . self ) ...", + "text": "Now you can add your model to the config's prearations so the database is prepared when your application boots. import Vapor import FluentProvider let config = try Config () config . preparations . append ( Pet . self ) let drop = try Droplet ( config ) ...", "title": "Add to Droplet" }, { @@ -1202,7 +1207,7 @@ }, { "location": "/fluent/database/", - "text": "Database\n\n\nA Fluent database is responsible for managing connections to your underlying data store and sending queries to the implementation-specific driver you have chosen.\n\n\nDrivers\n\n\nBy default, Fluent includes in-memory and SQLite drivers. There are several drivers available to add to your Vapor application.\n\n\nAvailable\n\n\n\n\n\n\n\n\nType\n\n\nKey\n\n\nPackage\n\n\nClass\n\n\nOfficial\n\n\n\n\n\n\n\n\n\n\nMemory\n\n\nmemory\n\n\nFluent Provider\n\n\nFluent.MemoryDriver\n\n\nYes\n\n\n\n\n\n\nSQlite\n\n\nsqlite\n\n\nFluent Provider\n\n\nFluent.SQLiteDriver\n\n\nYes\n\n\n\n\n\n\nMySQL\n\n\nmysql\n\n\nMySQLProvider\n\n\nMySQLDriver.Driver\n\n\nYes\n\n\n\n\n\n\nPostgreSQL\n\n\npostgresql\n\n\nPostgreSQLProvider\n\n\nPostgreSQLDriver.Driver\n\n\nNo\n\n\n\n\n\n\nMongoDB\n\n\nN/A\n\n\nMongoProvider\n\n\nN/A\n\n\nNo\n\n\n\n\n\n\n\n\nClick on the provider package for more information about how to use it.\n\n\nYou can search for a list of available \nVapor database providers\n on GitHub.\n\n\nDroplet\n\n\nYou can access the database from the Droplet.\n\n\ndrop\n.\ndatabase\n \n// Database?\n\n\n\n\n\n\nPreparations\n\n\nMost databases, like SQL databases, require the schema for a model to be created before it is stored. \nAdding a preparation to your model will allow you to prepare the database while your app boots.\n\n\nextension\n \nUser\n:\n \nPreparation\n \n{\n\n \n/// Prepares a table/collection in the database\n\n \n/// for storing Users\n\n \nstatic\n \nfunc\n \nprepare\n(\n_\n \ndatabase\n:\n \nDatabase\n)\n \nthrows\n \n{\n\n \ntry\n \ndatabase\n.\ncreate\n(\nself\n)\n \n{\n \nbuilder\n \nin\n\n \nbuilder\n.\nid\n()\n\n \nbuilder\n.\nstring\n(\nname\n)\n\n \nbuilder\n.\nint\n(\nage\n)\n\n \n}\n\n \n}\n\n\n \n/// Undoes what was done in `prepare`\n\n \nstatic\n \nfunc\n \nrevert\n(\n_\n \ndatabase\n:\n \nDatabase\n)\n \nthrows\n \n{\n\n \ntry\n \ndatabase\n.\ndelete\n(\nself\n)\n\n \n}\n\n\n}\n\n\n\n\n\n\nThe above prepare statement results in SQL similar to the following:\n\n\nCREATE\n \nTABLE\n \n`\nusers\n`\n \n(\n`\nid\n`\n \nINTEGER\n \nPRIMARY\n \nKEY\n \nNOT\n \nNULL\n,\n \n`\nname\n`\n \nTEXT\n \nNOT\n \nNULL\n,\n \n`\nage\n`\n \nINTEGER\n \nNOT\n \nNULL\n)\n\n\n\n\n\n\nOnce you have created you preparation, add it to the Droplet's prepratations array.\n\n\ndrop\n.\npreparations\n.\nappend\n(\nUser\n.\nself\n)\n\n\n\n\n\n\nCreate\n\n\nThe following methods are available on while creating and modifing the database.\n\n\n\n\n\n\n\n\nMethod\n\n\nType\n\n\n\n\n\n\n\n\n\n\nid\n\n\nPrimary Identifier\n\n\n\n\n\n\nforeignId\n\n\nForeign Identifier\n\n\n\n\n\n\nint\n\n\nInteger\n\n\n\n\n\n\nstring\n\n\nString\n\n\n\n\n\n\ndouble\n\n\nDouble\n\n\n\n\n\n\nbool\n\n\nBoolean\n\n\n\n\n\n\nbytes\n\n\nData\n\n\n\n\n\n\ndate\n\n\nDate + Time\n\n\n\n\n\n\n\n\nYou can use any of these methods on a builder inside \n.create()\n.\n\n\ntry\n \ndatabase\n.\ncreate\n(\nself\n)\n \n{\n \nbuilder\n \nin\n\n \nbuilder\n.\ndouble\n(\nlatitude\n)\n\n \nbuilder\n.\ndouble\n(\nlongitude\n)\n\n\n}\n\n\n\n\n\n\nForeign Keys\n\n\nForeign keys are automatically added with \n.foreignId()\n. To add a foreign key manually, use the\n\n.foreignKey\n method.\n\n\ntry\n \ndatabase\n.\ncreate\n(\nself\n)\n \n{\n \nbuilder\n \nin\n\n \nbuilder\n.\nforeignKey\n(\nuser_id\n,\n \nreferences\n:\n \nid\n,\n \non\n:\n \nUser\n.\nself\n)\n\n\n}\n\n\n\n\n\n\nTo disable automatic foreign keys, set \nautoForeignKeys\n to false in the \nConfig/fluent.json\n file.\n\n\n{\n\n \nautoForeignKeys\n:\n \nfalse\n\n\n}\n\n\n\n\n\n\nModifier\n\n\nExisting schema can be modified using the \n.modify()\n property. All of the methods from \n.create()\n\nare available here as well.\n\n\ntry\n \ndatabase\n.\nmodify\n(\nself\n)\n \n{\n \nbuilder\n \nin\n\n \nbuilder\n.\nstring\n(\nname\n)\n\n \nbuilder\n.\ndelete\n(\nage\n)\n\n\n}\n\n\n\n\n\n\nMigrations\n\n\nOther times, you may want to make some modifications to your data set while migrating to a new version or\njust performing general cleanup. \n\n\nstruct\n \nDeleteOldEntries\n:\n \nPreparation\n \n{\n\n \nstatic\n \nfunc\n \nprepare\n(\n_\n \ndatabase\n:\n \nDatabase\n)\n \nthrows\n \n{\n\n \ntry\n \nLog\n.\nmakeQuery\n().\nfilter\n(...).\ndelete\n()\n\n \n}\n\n\n \n...\n\n\n}\n\n\n\n\n\n\nRun\n\n\nYour preparations will run every time you run your application. You can run your preparations without booting\nyour server by calling:\n\n\nvapor run prepare\n\n\n\n\n\nRevert\n\n\nUse the revert method to undo any work you did in the prepare method. \n\n\nextension\n \nUser\n:\n \nPreparation\n \n{\n\n \n...\n\n\n\n \nstatic\n \nfunc\n \nrevert\n(\n_\n \ndatabase\n:\n \nDatabase\n)\n \nthrows\n \n{\n\n \ntry\n \ndatabase\n.\ndelete\n(\nself\n)\n\n \n}\n\n\n}\n\n\n\n\n\n\nYou can run the reversions by calling:\n\n\nvapor run prepare --revert\n\n\n\n\n\nThis will revert the latest batch of preparations. To revert the entire database, run the following:\n\n\nvapor run prepare --revert --all\n\n\n\n\n\nLog\n\n\nLogging queries is a great way to find optimizations for your application and track down bugs.\n\n\ndrop\n.\ndatabase\n?.\nlog\n \n=\n \n{\n \nquery\n \nin\n\n \nprint\n(\nquery\n)\n\n\n}\n\n\n\n\n\n\nYou can assign a closure to the \nlog\n property on the database. Any time a query is run, the closure\nwill be called with a \nQueryLog\n object containing a string describing the statement and the time it ran.\n\n\nTransactions\n\n\nTransactions allow you to group multiple queries into one single unit of work. If any one of the \nqueries experiences a problem, the entire transaction will be rolled back.\n\n\ndrop\n.\ndatabase\n?.\ntransaction\n \n{\n \nconn\n \nin\n\n \ntry\n \nuser\n.\npets\n.\nmakeQuery\n(\nconn\n).\ndelete\n()\n\n \ntry\n \nuser\n.\nmakeQuery\n(\nconn\n).\ndelete\n()\n\n\n}\n\n\n\n\n\n\nDrivers that do not support transactions will throw an error if this method is called.\n\n\nYou can use the \n.makeQuery(_: Executor)\n method to create queries that will run on the \nconnection supplied to the closure.\n\n\n\n\nWarning\n\n\nYou must use the connection supplied to the closure for queries you want to include\nin the transaction.\n\n\n\n\nIndexes\n\n\nAn index is a copy of selected columns of data from a table that can be searched very efficiently.\n\n\nYou can add them to your database by calling \n.index()\n\n\ntry\n \ndatabase\n.\nindex\n(\nname\n,\n \nfor\n:\n \nUser\n.\nself\n)\n\n\n\n\n\n\nYou can delete them by calling \n.deleteIndex()\n\n\ntry\n \ndatabase\n.\ndeleteIndex\n(\nname\n,\n \nfor\n:\n \nUser\n.\nself\n)", + "text": "Database\n\n\nA Fluent database is responsible for managing connections to your underlying data store and sending queries to the implementation-specific driver you have chosen.\n\n\nDrivers\n\n\nBy default, Fluent includes in-memory and SQLite drivers. There are several drivers available to add to your Vapor application.\n\n\nAvailable\n\n\n\n\n\n\n\n\nType\n\n\nKey\n\n\nPackage\n\n\nClass\n\n\nOfficial\n\n\n\n\n\n\n\n\n\n\nMemory\n\n\nmemory\n\n\nFluent Provider\n\n\nFluent.MemoryDriver\n\n\nYes\n\n\n\n\n\n\nSQlite\n\n\nsqlite\n\n\nFluent Provider\n\n\nFluent.SQLiteDriver\n\n\nYes\n\n\n\n\n\n\nMySQL\n\n\nmysql\n\n\nMySQLProvider\n\n\nMySQLDriver.Driver\n\n\nYes\n\n\n\n\n\n\nPostgreSQL\n\n\npostgresql\n\n\nPostgreSQLProvider\n\n\nPostgreSQLDriver.Driver\n\n\nNo\n\n\n\n\n\n\nMongoDB\n\n\nN/A\n\n\nMongoProvider\n\n\nN/A\n\n\nNo\n\n\n\n\n\n\n\n\nClick on the provider package for more information about how to use it.\n\n\nYou can search for a list of available \nVapor database providers\n on GitHub.\n\n\nDroplet\n\n\nYou can access the database from the Droplet.\n\n\ndrop\n.\ndatabase\n \n// Database?\n\n\n\n\n\n\nPreparations\n\n\nMost databases, like SQL databases, require the schema for a model to be created before it is stored. \nAdding a preparation to your model will allow you to prepare the database while your app boots.\n\n\nextension\n \nUser\n:\n \nPreparation\n \n{\n\n \n/// Prepares a table/collection in the database\n\n \n/// for storing Users\n\n \nstatic\n \nfunc\n \nprepare\n(\n_\n \ndatabase\n:\n \nDatabase\n)\n \nthrows\n \n{\n\n \ntry\n \ndatabase\n.\ncreate\n(\nself\n)\n \n{\n \nbuilder\n \nin\n\n \nbuilder\n.\nid\n()\n\n \nbuilder\n.\nstring\n(\nname\n)\n\n \nbuilder\n.\nint\n(\nage\n)\n\n \n}\n\n \n}\n\n\n \n/// Undoes what was done in `prepare`\n\n \nstatic\n \nfunc\n \nrevert\n(\n_\n \ndatabase\n:\n \nDatabase\n)\n \nthrows\n \n{\n\n \ntry\n \ndatabase\n.\ndelete\n(\nself\n)\n\n \n}\n\n\n}\n\n\n\n\n\n\nThe above prepare statement results in SQL similar to the following:\n\n\nCREATE\n \nTABLE\n \n`\nusers\n`\n \n(\n`\nid\n`\n \nINTEGER\n \nPRIMARY\n \nKEY\n \nNOT\n \nNULL\n,\n \n`\nname\n`\n \nTEXT\n \nNOT\n \nNULL\n,\n \n`\nage\n`\n \nINTEGER\n \nNOT\n \nNULL\n)\n\n\n\n\n\n\nOnce you have created you preparation, add it to the Config's prepratations array.\n\n\nconfig\n.\npreparations\n.\nappend\n(\nUser\n.\nself\n)\n\n\n\n\n\n\nCreate\n\n\nThe following methods are available on while creating and modifing the database.\n\n\n\n\n\n\n\n\nMethod\n\n\nType\n\n\n\n\n\n\n\n\n\n\nid\n\n\nPrimary Identifier\n\n\n\n\n\n\nforeignId\n\n\nForeign Identifier\n\n\n\n\n\n\nint\n\n\nInteger\n\n\n\n\n\n\nstring\n\n\nString\n\n\n\n\n\n\ndouble\n\n\nDouble\n\n\n\n\n\n\nbool\n\n\nBoolean\n\n\n\n\n\n\nbytes\n\n\nData\n\n\n\n\n\n\ndate\n\n\nDate + Time\n\n\n\n\n\n\n\n\nYou can use any of these methods on a builder inside \n.create()\n.\n\n\ntry\n \ndatabase\n.\ncreate\n(\nself\n)\n \n{\n \nbuilder\n \nin\n\n \nbuilder\n.\ndouble\n(\nlatitude\n)\n\n \nbuilder\n.\ndouble\n(\nlongitude\n)\n\n\n}\n\n\n\n\n\n\nForeign Keys\n\n\nForeign keys are automatically added with \n.foreignId()\n. To add a foreign key manually, use the\n\n.foreignKey\n method.\n\n\ntry\n \ndatabase\n.\ncreate\n(\nself\n)\n \n{\n \nbuilder\n \nin\n\n \nbuilder\n.\nforeignKey\n(\nuser_id\n,\n \nreferences\n:\n \nid\n,\n \non\n:\n \nUser\n.\nself\n)\n\n\n}\n\n\n\n\n\n\nTo disable automatic foreign keys, set \nautoForeignKeys\n to false in the \nConfig/fluent.json\n file.\n\n\n{\n\n \nautoForeignKeys\n:\n \nfalse\n\n\n}\n\n\n\n\n\n\nModifier\n\n\nExisting schema can be modified using the \n.modify()\n property. All of the methods from \n.create()\n\nare available here as well.\n\n\ntry\n \ndatabase\n.\nmodify\n(\nself\n)\n \n{\n \nbuilder\n \nin\n\n \nbuilder\n.\nstring\n(\nname\n)\n\n \nbuilder\n.\ndelete\n(\nage\n)\n\n\n}\n\n\n\n\n\n\nMigrations\n\n\nOther times, you may want to make some modifications to your data set while migrating to a new version or\njust performing general cleanup. \n\n\nstruct\n \nDeleteOldEntries\n:\n \nPreparation\n \n{\n\n \nstatic\n \nfunc\n \nprepare\n(\n_\n \ndatabase\n:\n \nDatabase\n)\n \nthrows\n \n{\n\n \ntry\n \nLog\n.\nmakeQuery\n().\nfilter\n(...).\ndelete\n()\n\n \n}\n\n\n \n...\n\n\n}\n\n\n\n\n\n\nRun\n\n\nYour preparations will run every time you run your application. You can run your preparations without booting\nyour server by calling:\n\n\nvapor run prepare\n\n\n\n\n\nRevert\n\n\nUse the revert method to undo any work you did in the prepare method. \n\n\nextension\n \nUser\n:\n \nPreparation\n \n{\n\n \n...\n\n\n\n \nstatic\n \nfunc\n \nrevert\n(\n_\n \ndatabase\n:\n \nDatabase\n)\n \nthrows\n \n{\n\n \ntry\n \ndatabase\n.\ndelete\n(\nself\n)\n\n \n}\n\n\n}\n\n\n\n\n\n\nYou can run the reversions by calling:\n\n\nvapor run prepare --revert\n\n\n\n\n\nThis will revert the latest batch of preparations. To revert the entire database, run the following:\n\n\nvapor run prepare --revert --all\n\n\n\n\n\nLog\n\n\nLogging queries is a great way to find optimizations for your application and track down bugs.\n\n\ndrop\n.\ndatabase\n?.\nlog\n \n=\n \n{\n \nquery\n \nin\n\n \nprint\n(\nquery\n)\n\n\n}\n\n\n\n\n\n\nYou can assign a closure to the \nlog\n property on the database. Any time a query is run, the closure\nwill be called with a \nQueryLog\n object containing a string describing the statement and the time it ran.\n\n\nTransactions\n\n\nTransactions allow you to group multiple queries into one single unit of work. If any one of the \nqueries experiences a problem, the entire transaction will be rolled back.\n\n\ndrop\n.\ndatabase\n?.\ntransaction\n \n{\n \nconn\n \nin\n\n \ntry\n \nuser\n.\npets\n.\nmakeQuery\n(\nconn\n).\ndelete\n()\n\n \ntry\n \nuser\n.\nmakeQuery\n(\nconn\n).\ndelete\n()\n\n\n}\n\n\n\n\n\n\nDrivers that do not support transactions will throw an error if this method is called.\n\n\nYou can use the \n.makeQuery(_: Executor)\n method to create queries that will run on the \nconnection supplied to the closure.\n\n\n\n\nWarning\n\n\nYou must use the connection supplied to the closure for queries you want to include\nin the transaction.\n\n\n\n\nIndexes\n\n\nAn index is a copy of selected columns of data from a table that can be searched very efficiently.\n\n\nYou can add them to your database by calling \n.index()\n\n\ntry\n \ndatabase\n.\nindex\n(\nname\n,\n \nfor\n:\n \nUser\n.\nself\n)\n\n\n\n\n\n\nYou can delete them by calling \n.deleteIndex()\n\n\ntry\n \ndatabase\n.\ndeleteIndex\n(\nname\n,\n \nfor\n:\n \nUser\n.\nself\n)", "title": "Database" }, { @@ -1227,7 +1232,7 @@ }, { "location": "/fluent/database/#preparations", - "text": "Most databases, like SQL databases, require the schema for a model to be created before it is stored. \nAdding a preparation to your model will allow you to prepare the database while your app boots. extension User : Preparation { \n /// Prepares a table/collection in the database \n /// for storing Users \n static func prepare ( _ database : Database ) throws { \n try database . create ( self ) { builder in \n builder . id () \n builder . string ( name ) \n builder . int ( age ) \n } \n } \n\n /// Undoes what was done in `prepare` \n static func revert ( _ database : Database ) throws { \n try database . delete ( self ) \n } } The above prepare statement results in SQL similar to the following: CREATE TABLE ` users ` ( ` id ` INTEGER PRIMARY KEY NOT NULL , ` name ` TEXT NOT NULL , ` age ` INTEGER NOT NULL ) Once you have created you preparation, add it to the Droplet's prepratations array. drop . preparations . append ( User . self )", + "text": "Most databases, like SQL databases, require the schema for a model to be created before it is stored. \nAdding a preparation to your model will allow you to prepare the database while your app boots. extension User : Preparation { \n /// Prepares a table/collection in the database \n /// for storing Users \n static func prepare ( _ database : Database ) throws { \n try database . create ( self ) { builder in \n builder . id () \n builder . string ( name ) \n builder . int ( age ) \n } \n } \n\n /// Undoes what was done in `prepare` \n static func revert ( _ database : Database ) throws { \n try database . delete ( self ) \n } } The above prepare statement results in SQL similar to the following: CREATE TABLE ` users ` ( ` id ` INTEGER PRIMARY KEY NOT NULL , ` name ` TEXT NOT NULL , ` age ` INTEGER NOT NULL ) Once you have created you preparation, add it to the Config's prepratations array. config . preparations . append ( User . self )", "title": "Preparations" }, { @@ -2277,7 +2282,7 @@ }, { "location": "/http/client/", - "text": "Client\n\n\nThe client provided by \nHTTP\n is used to make outgoing requests to remote servers. Let's look at a simple outgoing request.\n\n\nQuickStart\n\n\nLet's jump right in to make a simple HTTP Request. Here's a basic \nGET\n request using your Vapor \nDroplet\n.\n\n\nlet\n \nquery\n \n=\n \n...\n\n\nlet\n \nres\n \n=\n \ntry\n \ndrop\n.\nclient\n.\nget\n(\nhttps://api.spotify.com/v1/search?type=artist\nq=\n\\(\nquery\n)\n)\n\n\nprint\n(\nres\n)\n\n\n\n\n\n\nClean Up\n\n\nThe url above can be a little tricky to read, so let's use the query parameter to clean it up a little bit:\n\n\nlet\n \nres\n \n=\n \ntry\n \ndrop\n.\nclient\n.\nget\n(\nhttps://api.spotify.com/v1/search\n,\n \nquery\n:\n \n[\n\n \ntype\n:\n \nartist\n,\n \n \nq\n:\n \nquery\n\n\n])\n\n\n\n\n\n\nContinued\n\n\nIn addition to \nGET\n requests, Vapor's client provides support for most common HTTP functions. \nGET\n, \nPOST\n, \nPUT\n, \nPATCH\n, \nDELETE\n\n\nHeaders\n\n\nYou can also add additional headers to the request.\n\n\ntry\n \ndrop\n.\nclient\n.\nget\n(\nhttp://some-endpoint/json\n,\n \nheaders\n:\n \n[\n\n \nAPI-Key\n:\n \nvapor123\n\n\n])\n\n\n\n\n\n\nCustom Request\n\n\nYou can ask the client to respond to any \nRequest\n that you create. \nThis is useful if you need to add JSON or FormURLEncoded data to the request.\n\n\nlet\n \nreq\n \n=\n \nRequest\n(\nmethod\n:\n \n.\npost\n,\n \nuri\n:\n \nhttp://some-endpoint\n)\n\n\nreq\n.\nformURLEncoded\n \n=\n \nNode\n(\nnode\n:\n \n[\n\n \nemail\n:\n \nmymail@vapor.codes\n\n\n])\n\n\n\ntry\n \ndrop\n.\nclient\n.\nresponse\n(\nto\n:\n \nreq\n)\n\n\n\n\n\n\nRe-usable Connection\n\n\nUp to this point, we've been using \ndrop.client\n which is a \nClientFactory\n. This creates a new client and TCP connection for each request.\n\n\nFor more better performance, you can create an re-use a single client.\n\n\nlet\n \npokemonClient\n \n=\n \ntry\n \ndrop\n.\nclient\n.\nmakeClient\n(\n\n \nscheme\n:\n \nhttp\n,\n \n \nhost\n:\n \npokeapi.co\n,\n\n \nsecurityLayer\n:\n \n.\nnone\n\n\n)\n\n\n\nfor\n \ni\n \nin\n \n0.\n..\n1\n \n{\n\n \nlet\n \nresponse\n \n=\n \ntry\n \npokemonClient\n.\nget\n(\n/api/v2/pokemon/\n,\n \nquery\n:\n \n[\n\n \nlimit\n:\n \n20\n,\n \n \noffset\n:\n \ni\n\n \n])\n\n \nprint\n(\nresponse: \n\\(\nresponse\n)\n)\n\n\n}\n\n\n\n\n\n\n\n\nNote\n\n\nClients created using \n.makeClient\n can not connect to a different server after initialization. (Proxy servers are an exception)\n\n\n\n\nProxy\n\n\nThe \ndrop.client\n can be configured to use a proxy by default.\n\n\nConfig/client.json\n\n\n{\n\n \nproxy\n:\n \n{\n\n \nhostname\n:\n \ngoogle.com\n,\n \n \nport\n:\n \n80\n,\n\n \nsecurityLayer\n:\n \nnone\n\n \n}\n\n\n}\n\n\n\n\n\n\nFor the above example, all requests sent to \ndrop.client.get(...)\n would be proxied through google.com.", + "text": "Client\n\n\nThe client provided by \nHTTP\n is used to make outgoing requests to remote servers. Let's look at a simple outgoing request.\n\n\nQuickStart\n\n\nLet's jump right in to make a simple HTTP Request. Here's a basic \nGET\n request using your Vapor \nDroplet\n.\n\n\nlet\n \nquery\n \n=\n \n...\n\n\nlet\n \nres\n \n=\n \ntry\n \ndrop\n.\nclient\n.\nget\n(\nhttps://api.spotify.com/v1/search?type=artist\nq=\n\\(\nquery\n)\n)\n\n\nprint\n(\nres\n)\n\n\n\n\n\n\nClean Up\n\n\nThe url above can be a little tricky to read, so let's use the query parameter to clean it up a little bit:\n\n\nlet\n \nres\n \n=\n \ntry\n \ndrop\n.\nclient\n.\nget\n(\nhttps://api.spotify.com/v1/search\n,\n \nquery\n:\n \n[\n\n \ntype\n:\n \nartist\n,\n \n \nq\n:\n \nquery\n\n\n])\n\n\n\n\n\n\nContinued\n\n\nIn addition to \nGET\n requests, Vapor's client provides support for most common HTTP functions. \nGET\n, \nPOST\n, \nPUT\n, \nPATCH\n, \nDELETE\n\n\nHeaders\n\n\nYou can also add additional headers to the request.\n\n\ntry\n \ndrop\n.\nclient\n.\nget\n(\nhttp://some-endpoint/json\n,\n \nheaders\n:\n \n[\n\n \nAPI-Key\n:\n \nvapor123\n\n\n])\n\n\n\n\n\n\nCustom Request\n\n\nYou can ask the client to respond to any \nRequest\n that you create. \nThis is useful if you need to add JSON or FormURLEncoded data to the request.\n\n\nlet\n \nreq\n \n=\n \nRequest\n(\nmethod\n:\n \n.\npost\n,\n \nuri\n:\n \nhttp://some-endpoint\n)\n\n\nreq\n.\nformURLEncoded\n \n=\n \nNode\n(\nnode\n:\n \n[\n\n \nemail\n:\n \nmymail@vapor.codes\n\n\n])\n\n\n\ntry\n \ndrop\n.\nclient\n.\nrespond\n(\nto\n:\n \nreq\n)\n\n\n\n\n\n\nRe-usable Connection\n\n\nUp to this point, we've been using \ndrop.client\n which is a \nClientFactory\n. This creates a new client and TCP connection for each request.\n\n\nFor more better performance, you can create an re-use a single client.\n\n\nlet\n \npokemonClient\n \n=\n \ntry\n \ndrop\n.\nclient\n.\nmakeClient\n(\n\n \nscheme\n:\n \nhttp\n,\n \n \nhost\n:\n \npokeapi.co\n,\n\n \nsecurityLayer\n:\n \n.\nnone\n\n\n)\n\n\n\nfor\n \ni\n \nin\n \n0.\n..\n1\n \n{\n\n \nlet\n \nresponse\n \n=\n \ntry\n \npokemonClient\n.\nget\n(\n/api/v2/pokemon/\n,\n \nquery\n:\n \n[\n\n \nlimit\n:\n \n20\n,\n \n \noffset\n:\n \ni\n\n \n])\n\n \nprint\n(\nresponse: \n\\(\nresponse\n)\n)\n\n\n}\n\n\n\n\n\n\n\n\nNote\n\n\nClients created using \n.makeClient\n can not connect to a different server after initialization. (Proxy servers are an exception)\n\n\n\n\nProxy\n\n\nThe \ndrop.client\n can be configured to use a proxy by default.\n\n\nConfig/client.json\n\n\n{\n\n \nproxy\n:\n \n{\n\n \nhostname\n:\n \ngoogle.com\n,\n \n \nport\n:\n \n80\n,\n\n \nsecurityLayer\n:\n \nnone\n\n \n}\n\n\n}\n\n\n\n\n\n\nFor the above example, all requests sent to \ndrop.client.get(...)\n would be proxied through google.com.", "title": "Client" }, { @@ -2307,7 +2312,7 @@ }, { "location": "/http/client/#custom-request", - "text": "You can ask the client to respond to any Request that you create. \nThis is useful if you need to add JSON or FormURLEncoded data to the request. let req = Request ( method : . post , uri : http://some-endpoint ) req . formURLEncoded = Node ( node : [ \n email : mymail@vapor.codes ]) try drop . client . response ( to : req )", + "text": "You can ask the client to respond to any Request that you create. \nThis is useful if you need to add JSON or FormURLEncoded data to the request. let req = Request ( method : . post , uri : http://some-endpoint ) req . formURLEncoded = Node ( node : [ \n email : mymail@vapor.codes ]) try drop . client . respond ( to : req )", "title": "Custom Request" }, { @@ -2452,7 +2457,7 @@ }, { "location": "/leaf/provider/", - "text": "Leaf Provider\n\n\nAfter you've \nadded the Leaf Provider package\n to your project, setting the provider up in code is easy.\n\n\nAdd to Droplet\n\n\nFirst, register the \nLeafProvider.Provider\n with your Droplet.\n\n\nimport\n \nVapor\n\n\nimport\n \nLeafProvider\n\n\n\nlet\n \nconfig\n \n=\n \ntry\n \nConfig\n()\n\n\ntry\n \nconfig\n.\naddProvider\n(\nLeafProvider\n.\nProvider\n.\nself\n)\n\n\n\nlet\n \ndrop\n \n=\n \ntry\n \nDroplet\n(\nconfig\n)\n\n\n\n...\n\n\n\n\n\n\nConfigure Droplet\n\n\nOnce the provider is added to your Droplet, you can configure your Droplet to use the Leaf view renderer.\n\n\nConfig/droplet.json\n\n\n{\n\n \n...,\n\n \nview\n:\n \nleaf\n,\n\n \n...\n\n\n}\n\n\n\n\n\n\n\n\nSeealso\n\n\nLearn more about configuration files in the \nSettings guide\n.\n\n\n\n\nManual\n\n\nYou can also set the \ndrop.view\n property manually if you want to hardcode your view renderer.\n\n\nimport\n \nVapor\n\n\nimport\n \nLeafProvider\n\n\n\nlet\n \ndrop\n \n=\n \ntry\n \nDroplet\n()\n\n\n\ndrop\n.\nview\n \n=\n \nLeafRenderer\n(\nviewsDir\n:\n \ndrop\n.\nviewsDir\n)\n\n\n\n\n\n\nDone\n\n\nNext time you boot your application, your views will be rendered using Leaf.", + "text": "Leaf Provider\n\n\nAfter you've \nadded the Leaf Provider package\n to your project, setting the provider up in code is easy.\n\n\nAdd to Droplet\n\n\nFirst, register the \nLeafProvider.Provider\n with your Droplet.\n\n\nimport\n \nVapor\n\n\nimport\n \nLeafProvider\n\n\n\nlet\n \nconfig\n \n=\n \ntry\n \nConfig\n()\n\n\ntry\n \nconfig\n.\naddProvider\n(\nLeafProvider\n.\nProvider\n.\nself\n)\n\n\n\nlet\n \ndrop\n \n=\n \ntry\n \nDroplet\n(\nconfig\n)\n\n\n\n...\n\n\n\n\n\n\nConfigure Droplet\n\n\nOnce the provider is added to your Droplet, you can configure your Droplet to use the Leaf view renderer.\n\n\nConfig/droplet.json\n\n\n{\n\n \n...,\n\n \nview\n:\n \nleaf\n,\n\n \n...\n\n\n}\n\n\n\n\n\n\n\n\nSeealso\n\n\nLearn more about configuration files in the \nSettings guide\n.\n\n\n\n\nManual\n\n\nYou can also set the \ndrop.view\n property manually if you want to hardcode your view renderer.\n\n\nimport\n \nVapor\n\n\nimport\n \nLeafProvider\n\n\n\nlet\n \nview\n \n=\n \nLeafRenderer\n(\nviewsDir\n:\n \ndrop\n.\nviewsDir\n)\n\n\nlet\n \ndrop\n \n=\n \ntry\n \nDroplet\n(\nview\n:\n \nview\n)\n\n\n\n\n\n\nDone\n\n\nNext time you boot your application, your views will be rendered using Leaf.", "title": "Provider" }, { @@ -2472,7 +2477,7 @@ }, { "location": "/leaf/provider/#manual", - "text": "You can also set the drop.view property manually if you want to hardcode your view renderer. import Vapor import LeafProvider let drop = try Droplet () drop . view = LeafRenderer ( viewsDir : drop . viewsDir )", + "text": "You can also set the drop.view property manually if you want to hardcode your view renderer. import Vapor import LeafProvider let view = LeafRenderer ( viewsDir : drop . viewsDir ) let drop = try Droplet ( view : view )", "title": "Manual" }, { @@ -2605,10 +2610,30 @@ "text": "Some preliminary work has been done to implement a Leaf Plugin for CLion AppCode but lack of skill and interest in Java has slowed progress! If you have IntelliJ SDK experience and want to help with this, message Tom Holland on Vapor Slack", "title": "CLion & AppCode" }, + { + "location": "/validation/package/", + "text": "Using Validation\n\n\nThis section outlines how to import the Validation package both with or without a Vapor project.\n\n\nWith Vapor\n\n\nThe easiest way to use Validation with Vapor is to include the Validation provider. \n\n\nimport\n \nPackageDescription\n\n\n\nlet\n \npackage\n \n=\n \nPackage\n(\n\n \nname\n:\n \nProject\n,\n\n \ndependencies\n:\n \n[\n\n \n.\nPackage\n(\nurl\n:\n \nhttps://github.com/vapor/vapor.git\n,\n \nmajorVersion\n:\n \n2\n),\n\n \n.\nPackage\n(\nurl\n:\n \nhttps://github.com/vapor/validation-provider.git\n,\n \nmajorVersion\n:\n \n1\n)\n\n \n],\n\n \nexclude\n:\n \n[\n \n...\n \n]\n\n\n)\n\n\n\n\n\n\nThe Validation provider package adds Validation to your project and adds some additional, vapor-specific conveniences like validation middleware. \n\n\nUsing \nimport ValidationProvider\n will import the Validation middleware and the Validation module. \n\n\nJust Validation\n\n\nAt the core of the Validation provider is a Validation module.\n\n\nimport\n \nPackageDescription\n\n\n\nlet\n \npackage\n \n=\n \nPackage\n(\n\n \nname\n:\n \nProject\n,\n\n \ndependencies\n:\n \n[\n\n \n...\n\n \n.\nPackage\n(\nurl\n:\n \nhttps://github.com/vapor/validation.git\n,\n \nmajorVersion\n:\n \n1\n)\n\n \n],\n\n \nexclude\n:\n \n[\n \n...\n \n]\n\n\n)\n\n\n\n\n\n\nUse \nimport Validation\n to access the core validation class.", + "title": "Package" + }, + { + "location": "/validation/package/#using-validation", + "text": "This section outlines how to import the Validation package both with or without a Vapor project.", + "title": "Using Validation" + }, + { + "location": "/validation/package/#with-vapor", + "text": "The easiest way to use Validation with Vapor is to include the Validation provider. import PackageDescription let package = Package ( \n name : Project , \n dependencies : [ \n . Package ( url : https://github.com/vapor/vapor.git , majorVersion : 2 ), \n . Package ( url : https://github.com/vapor/validation-provider.git , majorVersion : 1 ) \n ], \n exclude : [ ... ] ) The Validation provider package adds Validation to your project and adds some additional, vapor-specific conveniences like validation middleware. Using import ValidationProvider will import the Validation middleware and the Validation module.", + "title": "With Vapor" + }, + { + "location": "/validation/package/#just-validation", + "text": "At the core of the Validation provider is a Validation module. import PackageDescription let package = Package ( \n name : Project , \n dependencies : [ \n ... \n . Package ( url : https://github.com/vapor/validation.git , majorVersion : 1 ) \n ], \n exclude : [ ... ] ) Use import Validation to access the core validation class.", + "title": "Just Validation" + }, { "location": "/validation/overview/", "text": "Warning\n\n\nThis section may contain outdated information.\n\n\n\n\nValidation\n\n\nVapor provides a few different ways to validate data coming into your application. Let's start by looking at the most common.\n\n\nCommon Usage\n\n\nSeveral useful convenience validators are included by default. You can use these to validate data coming into your application, or combine them and create your own.\n\n\nLet's look at the most common way to validate data.\n\n\nclass\n \nEmployee\n \n{\n\n \nvar\n \nemail\n:\n \nValid\nEmail\n\n \nvar\n \nname\n:\n \nValid\nName\n\n\n \ninit\n(\nrequest\n:\n \nRequest\n)\n \nthrows\n \n{\n\n \nname\n \n=\n \ntry\n \nrequest\n.\ndata\n[\nname\n].\nvalidated\n()\n\n \nemail\n \n=\n \ntry\n \nrequest\n.\ndata\n[\nemail\n].\nvalidated\n()\n\n \n}\n\n\n}\n\n\n\n\n\n\nHere we have a typical Employee model with an \nemail\n and \nname\n property. By declaring both of these properties as \nValid\n, you are ensuring that these properties can only ever contain valid data. The Swift type checking system will prevent anything that does not pass validation from being stored.\n\n\nTo store something in a \nValid\n property, you must use the \n.validated()\n method. This is available for any data returned by \nrequest.data\n.\n\n\nEmail\n is a real \nvalidator\n included with Vapor, but \nName\n is not. Let's take a look at how you can create a Validator.\n\n\nValid\nOnlyAlphanumeric\n\n\nValid\nEmail\n\n\nValid\nUnique\nT\n\n\nValid\nMatches\nT\n\n\nValid\nIn\nT\n\n\nValid\nContains\nT\n\n\nValid\nCount\nT\n\n\n\n\n\n\nValidators vs. ValidationSuites\n\n\nValidators, like \nCount\n or \nContains\n can have multiple configurations. For example:\n\n\nlet\n \nname\n:\n \nValid\nCount\nString\n \n=\n \ntry\n \nVapor\n.\nvalidated\n(\nby\n:\n \nCount\n.\nmax\n(\n5\n))\n\n\n\n\n\n\nHere we are validating that the \nString\n is at most 5 characters long. The type of \nValid\nCount\n tells us that the string has been validated to be a certain count, but it does not tell us exactly what that count was. The string could have been validated to be less than three characters or more than one million.\n\n\nBecause of this, \nValidators\n themselves are not as type safe as some applications might desire. \nValidationSuites\n fix this. They combine multiple \nValidators\n and/or \nValidationSuites\n together to represent exactly what type of data should be considered valid.\n\n\nCustom Validator\n\n\nHere is how to create a custom \nValidationSuite\n.\n\n\nclass\n \nName\n:\n \nValidationSuite\n \n{\n\n \nstatic\n \nfunc\n \nvalidate\n(\ninput\n \nvalue\n:\n \nString\n)\n \nthrows\n \n{\n\n \nlet\n \nevaluation\n \n=\n \nOnlyAlphanumeric\n.\nself\n\n \n \nCount\n.\nmin\n(\n5\n)\n\n \n \nCount\n.\nmax\n(\n20\n)\n\n\n \ntry\n \nevaluation\n.\nvalidate\n(\ninput\n:\n \nvalue\n)\n\n \n}\n\n\n}\n\n\n\n\n\n\nYou only have to implement one method. In this method, use any other validators or logic to create your custom validator. Here we are defining a \nName\n as only accepting alphanumeric Strings that are between 5 and 20 characters.\n\n\nNow we can be sure that anything of type \nValid\nName\n follows these rules.\n\n\nCombining Validators\n\n\nIn the \nName\n validator, you can see that \n is being used to combine validators. You can use \n as well as \n||\n to combine any validator as you would boolean values with an \nif\n statement.\n\n\nYou can also use \n!\n to invert the validator.\n\n\nlet\n \nsymbols\n \n=\n \ninput\n.\nvalidated\n(\nby\n:\n \n!\nOnlyAlphanumeric\n.\nself\n)\n\n\n\n\n\n\nTesting Validity\n\n\nWhile \nvalidated() throw\n is the most common method for validating, there are two others.\n\n\nlet\n \npassed\n \n=\n \ninput\n.\npasses\n(\nCount\n.\nmin\n(\n5\n))\n\n\nlet\n \nvalid\n \n=\n \ntry\n \ninput\n.\ntested\n(\nCount\n.\nmin\n(\n5\n))\n\n\n\n\n\n\npasses()\n returns a boolean indicating whether or not the test passed. \ntested()\n will throw if the validation does not pass. But unlike \nvalidated()\n which returns a \nValid\n type, \ntested()\n returns the original type of the item it was called on.\n\n\nValidation Failures\n\n\nVapor will automatically catch validation failures in the \nValidationMiddleware\n. But you can catch them on your own, or customize responses for certain types of failures.\n\n\ndo\n \n{\n\n \n//validation here\n\n\n}\n \ncatch\n \nlet\n \nerror\n \nas\n \nValidationErrorProtocol\n \n{\n\n \nprint\n(\nerror\n.\nmessage\n)\n\n\n}", - "title": "Validation" + "title": "Overview" }, { "location": "/validation/overview/#validation", diff --git a/build/2.0/mysql/driver/index.html b/build/2.0/mysql/driver/index.html index 1c1e1bd8..1465e82d 100644 --- a/build/2.0/mysql/driver/index.html +++ b/build/2.0/mysql/driver/index.html @@ -1229,12 +1229,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/mysql/package/index.html b/build/2.0/mysql/package/index.html index 1e9b3a9e..eddd9194 100644 --- a/build/2.0/mysql/package/index.html +++ b/build/2.0/mysql/package/index.html @@ -1229,12 +1229,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/mysql/provider/index.html b/build/2.0/mysql/provider/index.html index b4881c51..712d0ece 100644 --- a/build/2.0/mysql/provider/index.html +++ b/build/2.0/mysql/provider/index.html @@ -1277,12 +1277,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/node/getting-started/index.html b/build/2.0/node/getting-started/index.html index 362dd797..9a1822ef 100644 --- a/build/2.0/node/getting-started/index.html +++ b/build/2.0/node/getting-started/index.html @@ -1179,12 +1179,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/node/package/index.html b/build/2.0/node/package/index.html index 8516d844..6b618190 100644 --- a/build/2.0/node/package/index.html +++ b/build/2.0/node/package/index.html @@ -1179,12 +1179,48 @@ -
  • - +
  • + + + + + +
  • + @@ -1614,7 +1650,7 @@ diff --git a/build/2.0/redis/package/index.html b/build/2.0/redis/package/index.html index 15245c0c..dc8e2453 100644 --- a/build/2.0/redis/package/index.html +++ b/build/2.0/redis/package/index.html @@ -1222,12 +1222,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/redis/provider/index.html b/build/2.0/redis/provider/index.html index 7de2f02e..19105f72 100644 --- a/build/2.0/redis/provider/index.html +++ b/build/2.0/redis/provider/index.html @@ -1256,12 +1256,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/routing/collection/index.html b/build/2.0/routing/collection/index.html index c02f99b2..1fb43f48 100644 --- a/build/2.0/routing/collection/index.html +++ b/build/2.0/routing/collection/index.html @@ -1222,12 +1222,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/routing/group/index.html b/build/2.0/routing/group/index.html index be1b759a..d27ba402 100644 --- a/build/2.0/routing/group/index.html +++ b/build/2.0/routing/group/index.html @@ -1243,12 +1243,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/routing/overview/index.html b/build/2.0/routing/overview/index.html index dcafce97..813b80ae 100644 --- a/build/2.0/routing/overview/index.html +++ b/build/2.0/routing/overview/index.html @@ -1277,12 +1277,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/routing/package/index.html b/build/2.0/routing/package/index.html index 93fe346b..2fbcba73 100644 --- a/build/2.0/routing/package/index.html +++ b/build/2.0/routing/package/index.html @@ -1222,12 +1222,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/routing/parameters/index.html b/build/2.0/routing/parameters/index.html index 6ff90c4e..2bb08b83 100644 --- a/build/2.0/routing/parameters/index.html +++ b/build/2.0/routing/parameters/index.html @@ -1242,12 +1242,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/sessions/package/index.html b/build/2.0/sessions/package/index.html index e9fd188d..5b7b896b 100644 --- a/build/2.0/sessions/package/index.html +++ b/build/2.0/sessions/package/index.html @@ -1190,12 +1190,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/sessions/sessions/index.html b/build/2.0/sessions/sessions/index.html index 01d85fa4..564e6c4e 100644 --- a/build/2.0/sessions/sessions/index.html +++ b/build/2.0/sessions/sessions/index.html @@ -1256,12 +1256,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/sitemap.xml b/build/2.0/sitemap.xml index bdfba429..9d37cbff 100644 --- a/build/2.0/sitemap.xml +++ b/build/2.0/sitemap.xml @@ -4,7 +4,7 @@ / - 2017-05-24 + 2017-06-02 daily @@ -13,37 +13,37 @@ /getting-started/install-on-macos/ - 2017-05-24 + 2017-06-02 daily /getting-started/install-on-ubuntu/ - 2017-05-24 + 2017-06-02 daily /getting-started/toolbox/ - 2017-05-24 + 2017-06-02 daily /getting-started/hello-world/ - 2017-05-24 + 2017-06-02 daily /getting-started/manual/ - 2017-05-24 + 2017-06-02 daily /getting-started/xcode/ - 2017-05-24 + 2017-06-02 daily @@ -53,49 +53,49 @@ /vapor/folder-structure/ - 2017-05-24 + 2017-06-02 daily /vapor/droplet/ - 2017-05-24 + 2017-06-02 daily /vapor/views/ - 2017-05-24 + 2017-06-02 daily /vapor/controllers/ - 2017-05-24 + 2017-06-02 daily /vapor/provider/ - 2017-05-24 + 2017-06-02 daily /vapor/hash/ - 2017-05-24 + 2017-06-02 daily /vapor/log/ - 2017-05-24 + 2017-06-02 daily /vapor/commands/ - 2017-05-24 + 2017-06-02 daily @@ -105,7 +105,7 @@ /configs/config/ - 2017-05-24 + 2017-06-02 daily @@ -115,13 +115,13 @@ /json/package/ - 2017-05-24 + 2017-06-02 daily /json/overview/ - 2017-05-24 + 2017-06-02 daily @@ -131,31 +131,31 @@ /routing/package/ - 2017-05-24 + 2017-06-02 daily /routing/overview/ - 2017-05-24 + 2017-06-02 daily /routing/parameters/ - 2017-05-24 + 2017-06-02 daily /routing/group/ - 2017-05-24 + 2017-06-02 daily /routing/collection/ - 2017-05-24 + 2017-06-02 daily @@ -165,37 +165,37 @@ /fluent/package/ - 2017-05-24 + 2017-06-02 daily /fluent/getting-started/ - 2017-05-24 + 2017-06-02 daily /fluent/model/ - 2017-05-24 + 2017-06-02 daily /fluent/database/ - 2017-05-24 + 2017-06-02 daily /fluent/query/ - 2017-05-24 + 2017-06-02 daily /fluent/relations/ - 2017-05-24 + 2017-06-02 daily @@ -205,13 +205,13 @@ /cache/package/ - 2017-05-24 + 2017-06-02 daily /cache/overview/ - 2017-05-24 + 2017-06-02 daily @@ -221,19 +221,19 @@ /mysql/package/ - 2017-05-24 + 2017-06-02 daily /mysql/provider/ - 2017-05-24 + 2017-06-02 daily /mysql/driver/ - 2017-05-24 + 2017-06-02 daily @@ -243,13 +243,13 @@ /redis/package/ - 2017-05-24 + 2017-06-02 daily /redis/provider/ - 2017-05-24 + 2017-06-02 daily @@ -259,37 +259,37 @@ /auth/package/ - 2017-05-24 + 2017-06-02 daily /auth/provider/ - 2017-05-24 + 2017-06-02 daily /auth/getting-started/ - 2017-05-24 + 2017-06-02 daily /auth/helper/ - 2017-05-24 + 2017-06-02 daily /auth/password/ - 2017-05-24 + 2017-06-02 daily /auth/persist/ - 2017-05-24 + 2017-06-02 daily @@ -299,13 +299,13 @@ /sessions/package/ - 2017-05-24 + 2017-06-02 daily /sessions/sessions/ - 2017-05-24 + 2017-06-02 daily @@ -315,61 +315,61 @@ /http/package/ - 2017-05-24 + 2017-06-02 daily /http/request/ - 2017-05-24 + 2017-06-02 daily /http/response/ - 2017-05-24 + 2017-06-02 daily /http/middleware/ - 2017-05-24 + 2017-06-02 daily /http/body/ - 2017-05-24 + 2017-06-02 daily /http/response-representable/ - 2017-05-24 + 2017-06-02 daily /http/responder/ - 2017-05-24 + 2017-06-02 daily /http/client/ - 2017-05-24 + 2017-06-02 daily /http/server/ - 2017-05-24 + 2017-06-02 daily /http/cors/ - 2017-05-24 + 2017-06-02 daily @@ -379,43 +379,51 @@ /leaf/package/ - 2017-05-24 + 2017-06-02 daily /leaf/provider/ - 2017-05-24 + 2017-06-02 daily /leaf/leaf/ - 2017-05-24 + 2017-06-02 daily + - /validation/overview/ - 2017-05-24 + /validation/package/ + 2017-06-02 daily + + + /validation/overview/ + 2017-06-02 + daily + + /node/package/ - 2017-05-24 + 2017-06-02 daily /node/getting-started/ - 2017-05-24 + 2017-06-02 daily @@ -425,13 +433,13 @@ /core/package/ - 2017-05-24 + 2017-06-02 daily /core/overview/ - 2017-05-24 + 2017-06-02 daily @@ -441,13 +449,13 @@ /bits/package/ - 2017-05-24 + 2017-06-02 daily /bits/overview/ - 2017-05-24 + 2017-06-02 daily @@ -457,13 +465,13 @@ /debugging/package/ - 2017-05-24 + 2017-06-02 daily /debugging/overview/ - 2017-05-24 + 2017-06-02 daily @@ -473,13 +481,13 @@ /deploy/nginx/ - 2017-05-24 + 2017-06-02 daily /deploy/supervisor/ - 2017-05-24 + 2017-06-02 daily @@ -489,19 +497,19 @@ /version/1_5/ - 2017-05-24 + 2017-06-02 daily /version/2_0/ - 2017-05-24 + 2017-06-02 daily /version/support/ - 2017-05-24 + 2017-06-02 daily diff --git a/build/2.0/validation/overview/index.html b/build/2.0/validation/overview/index.html index 56cace8a..7d3bc95e 100644 --- a/build/2.0/validation/overview/index.html +++ b/build/2.0/validation/overview/index.html @@ -15,7 +15,7 @@ - Validation - Vapor Docs + Overview - Vapor Docs @@ -76,8 +76,12 @@ + + Validation + + - Validation + Overview
    @@ -1177,6 +1181,39 @@ +
  • + + + + + +
  • + @@ -1722,7 +1764,7 @@ diff --git a/build/2.0/validation/package/index.html b/build/2.0/validation/package/index.html new file mode 100644 index 00000000..62fd6186 --- /dev/null +++ b/build/2.0/validation/package/index.html @@ -0,0 +1,1740 @@ + + + + + + + + + + + + + + + + + + Package - Vapor Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + +
    +
    +
    + + +
    +
    +
    + + +
    +
    + + edit + + + +

    Using Validation

    +

    This section outlines how to import the Validation package both with or without a Vapor project.

    +

    With Vapor

    +

    The easiest way to use Validation with Vapor is to include the Validation provider.

    +
    import PackageDescription
    +
    +let package = Package(
    +    name: "Project",
    +    dependencies: [
    +        .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 2),
    +        .Package(url: "https://github.com/vapor/validation-provider.git", majorVersion: 1)
    +    ],
    +    exclude: [ ... ]
    +)
    +
    + + +

    The Validation provider package adds Validation to your project and adds some additional, vapor-specific conveniences like validation middleware.

    +

    Using import ValidationProvider will import the Validation middleware and the Validation module.

    +

    Just Validation

    +

    At the core of the Validation provider is a Validation module.

    +
    import PackageDescription
    +
    +let package = Package(
    +    name: "Project",
    +    dependencies: [
    +        ...
    +        .Package(url: "https://github.com/vapor/validation.git", majorVersion: 1)
    +    ],
    +    exclude: [ ... ]
    +)
    +
    + + +

    Use import Validation to access the core validation class.

    + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + + \ No newline at end of file diff --git a/build/2.0/vapor/commands/index.html b/build/2.0/vapor/commands/index.html index 719b74c5..55687147 100644 --- a/build/2.0/vapor/commands/index.html +++ b/build/2.0/vapor/commands/index.html @@ -1190,12 +1190,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/vapor/controllers/index.html b/build/2.0/vapor/controllers/index.html index c4ee27f1..5a227524 100644 --- a/build/2.0/vapor/controllers/index.html +++ b/build/2.0/vapor/controllers/index.html @@ -1249,12 +1249,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/vapor/droplet/index.html b/build/2.0/vapor/droplet/index.html index c1f7b409..6b61ef7b 100644 --- a/build/2.0/vapor/droplet/index.html +++ b/build/2.0/vapor/droplet/index.html @@ -1283,12 +1283,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/vapor/folder-structure/index.html b/build/2.0/vapor/folder-structure/index.html index 64bb2cb6..24dfab5d 100644 --- a/build/2.0/vapor/folder-structure/index.html +++ b/build/2.0/vapor/folder-structure/index.html @@ -1243,12 +1243,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/vapor/hash/index.html b/build/2.0/vapor/hash/index.html index 3f24bc11..efb3ac17 100644 --- a/build/2.0/vapor/hash/index.html +++ b/build/2.0/vapor/hash/index.html @@ -1349,12 +1349,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/vapor/log/index.html b/build/2.0/vapor/log/index.html index 9d674a6e..28499cd8 100644 --- a/build/2.0/vapor/log/index.html +++ b/build/2.0/vapor/log/index.html @@ -1190,12 +1190,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/vapor/provider/index.html b/build/2.0/vapor/provider/index.html index 92b81179..86e53165 100644 --- a/build/2.0/vapor/provider/index.html +++ b/build/2.0/vapor/provider/index.html @@ -1276,12 +1276,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/vapor/views/index.html b/build/2.0/vapor/views/index.html index 767177d2..6142309a 100644 --- a/build/2.0/vapor/views/index.html +++ b/build/2.0/vapor/views/index.html @@ -1250,12 +1250,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/version/1_5/index.html b/build/2.0/version/1_5/index.html index 243eb8b7..bcd7cc00 100644 --- a/build/2.0/version/1_5/index.html +++ b/build/2.0/version/1_5/index.html @@ -1179,12 +1179,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/version/2_0/index.html b/build/2.0/version/2_0/index.html index a033c180..e551411a 100644 --- a/build/2.0/version/2_0/index.html +++ b/build/2.0/version/2_0/index.html @@ -1179,12 +1179,48 @@ -
  • - +
  • + + + + + +
  • + diff --git a/build/2.0/version/support/index.html b/build/2.0/version/support/index.html index c01361cb..f55c5600 100644 --- a/build/2.0/version/support/index.html +++ b/build/2.0/version/support/index.html @@ -1179,12 +1179,48 @@ -
  • - +
  • + + + + + +
  • +