What are Providers?

Providers are Swift packages that extend the functionality of a Vapor application. This is done by implementing the Provider protocol, which Vapor expects all Providers to have. The protocol is simple and is shown in the following code snippet:

public protocol Provider {  static var repositoryName: String { get }  static var publicDir: String { get }  static var viewsDir: String { get }  init(config: Config) throws  func boot(_ config: Config) throws  func boot(_ droplet: Droplet) throws  func beforeRun(_ droplet: Droplet) throws}

If you have a class that implements this Provider protocol, then you can use that class as a Provider in your Vapor application. Since you have config and droplet being passed into your Provider, you ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.