'created smparkinVaporWeb from template https://github.com/vapor/web-template'
This commit is contained in:
22
Sources/App/configure.swift
Normal file
22
Sources/App/configure.swift
Normal file
@@ -0,0 +1,22 @@
|
||||
import Leaf
|
||||
import Vapor
|
||||
|
||||
/// Called before your application initializes.
|
||||
public func configure(_ config: inout Config, _ env: inout Environment, _ services: inout Services) throws {
|
||||
// Register providers first
|
||||
try services.register(LeafProvider())
|
||||
|
||||
// Register routes to the router
|
||||
let router = EngineRouter.default()
|
||||
try routes(router)
|
||||
services.register(router, as: Router.self)
|
||||
|
||||
// Use Leaf for rendering views
|
||||
config.prefer(LeafRenderer.self, for: ViewRenderer.self)
|
||||
|
||||
// Register middleware
|
||||
var middlewares = MiddlewareConfig() // Create _empty_ middleware config
|
||||
middlewares.use(FileMiddleware.self) // Serves files from `Public/` directory
|
||||
middlewares.use(ErrorMiddleware.self) // Catches errors and converts to HTTP response
|
||||
services.register(middlewares)
|
||||
}
|
||||
Reference in New Issue
Block a user