'created CapCollectorServer from template https://github.com/twostraws/vapor-clean'

This commit is contained in:
christophhagen
2020-05-17 20:01:30 +02:00
commit bdbdcf2081
15 changed files with 224 additions and 0 deletions

9
Sources/App/boot.swift Executable file
View File

@ -0,0 +1,9 @@
import Routing
import Vapor
/// Called after your application has initialized.
///
/// [Learn More ](https://docs.vapor.codes/3.0/getting-started/structure/#bootswift)
public func boot(_ app: Application) throws {
// your code here
}

17
Sources/App/configure.swift Executable file
View File

@ -0,0 +1,17 @@
import Vapor
/// Called before your application initializes.
///
/// [Learn More ](https://docs.vapor.codes/3.0/getting-started/structure/#configureswift)
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)
// Configure the rest of your application here
}

11
Sources/App/routes.swift Executable file
View File

@ -0,0 +1,11 @@
import Routing
import Vapor
/// Register your application's routes here.
///
/// [Learn More ](https://docs.vapor.codes/3.0/getting-started/structure/#routesswift)
public func routes(_ router: Router) throws {
router.get("hello") { req in
return "Hello, world!"
}
}

26
Sources/Run/main.swift Executable file
View File

@ -0,0 +1,26 @@
import App
import Service
import Vapor
import Foundation
// The contents of main are wrapped in a do/catch block because any errors that get raised to the top level will crash Xcode
do {
var config = Config.default()
var env = try Environment.detect()
var services = Services.default()
try App.configure(&config, &env, &services)
let app = try Application(
config: config,
environment: env,
services: services
)
try App.boot(app)
try app.run()
} catch {
print(error)
exit(1)
}