Skip to content

Instantly share code, notes, and snippets.

@mczachurski
Created March 1, 2018 21:17
Show Gist options
  • Save mczachurski/25878c4d263baef80558a0bafa2a4694 to your computer and use it in GitHub Desktop.
Save mczachurski/25878c4d263baef80558a0bafa2a4694 to your computer and use it in GitHub Desktop.
// Authorization.
var routesWithAuthorization = Routes()
routesWithAuthorization.configure(routesWithAuthorization: controllers)
let requestFilters: [(HTTPRequestFilter, HTTPFilterPriority)] = [
(AuthenticationFilter(secret: configuration.secret, routesWithAuthorization: routesWithAuthorization), HTTPFilterPriority.high)
]
do {
// Launch the HTTP server.
try HTTPServer.launch(
.server(
name: configuration.serverName,
port: configuration.serverPort,
routes: allRoutes,
requestFilters: requestFilters
)
)
} 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