Skip to content

Instantly share code, notes, and snippets.

@mczachurski
Created February 13, 2018 19:37
Show Gist options
  • Save mczachurski/71e06e7a2f25bf4405fd64e775188bfd to your computer and use it in GitHub Desktop.
Save mczachurski/71e06e7a2f25bf4405fd64e775188bfd to your computer and use it in GitHub Desktop.
import PerfectHTTP
import PerfectHTTPServer
import PerfectLib
import Dip
// Configure dependency injection.
let container = DependencyContainer()
container.configure()
// Initialize all controllers.
let controllers = container.resolveAllControllers()
// Routes and handlers.
var routes = Routes()
routes.configure(basedOnControllers: controllers)
do {
// Launch the HTTP server.
try HTTPServer.launch(
.server(name: "www.example.ca", port: 8181, routes: routes))
} catch {
fatalError("\(error)") // fatal error launching one of the servers
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment