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 have an entry point to extend the Vapor application by adding additional routes and you also have a life cycle method that gets invoked before droplet.run()
is called, in case you need to perform an action before the server starts. There...