Files
smpark.in/Vapor3.1.10/Sources/App/configure.swift
2020-06-01 14:31:12 -07:00

22 lines
771 B
Swift

import Leaf
import Vapor
// Called before your application initializes.
public func configure(_ config: inout Config, _ env: inout Environment, _ services: inout Services) throws {
// Register routes to the router
let router = EngineRouter.default()
try routes(router)
services.register(router, as: Router.self)
//leaf
try services.register(LeafProvider())
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)
}