'created CapCollectorServer from template https://github.com/twostraws/vapor-clean'
This commit is contained in:
9
Sources/App/boot.swift
Executable file
9
Sources/App/boot.swift
Executable 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
17
Sources/App/configure.swift
Executable 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
11
Sources/App/routes.swift
Executable 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
26
Sources/Run/main.swift
Executable 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)
|
||||
}
|
Reference in New Issue
Block a user