feat: Minimal user api controller on hummingbird app, not sure there's big wins over vapor.
This commit is contained in:
@@ -3,7 +3,7 @@ import Hummingbird
|
||||
import Logging
|
||||
|
||||
@main
|
||||
struct App: AsyncParsableCommand {
|
||||
struct App: AsyncParsableCommand, AppArguments {
|
||||
|
||||
@Option(name: .shortAndLong)
|
||||
var hostname: String = "127.0.0.1"
|
||||
@@ -14,16 +14,28 @@ struct App: AsyncParsableCommand {
|
||||
@Option(name: .shortAndLong)
|
||||
var logLevel: Logger.Level?
|
||||
|
||||
@Flag(name: .shortAndLong)
|
||||
var migrate: Bool = false
|
||||
|
||||
@Flag(name: .shortAndLong)
|
||||
var revert: Bool = false
|
||||
|
||||
@Flag(name: .shortAndLong)
|
||||
var inMemoryDatabase: Bool = false
|
||||
|
||||
func run() async throws {
|
||||
let app = try await buildApplication(.init(hostname: hostname, port: port, logLevel: logLevel))
|
||||
let app = try await buildApplication(self)
|
||||
try await app.runService()
|
||||
}
|
||||
}
|
||||
|
||||
/// Extend `Logger.Level` so it can be used as an argument
|
||||
|
||||
#if hasFeature(RetroactiveAttribute)
|
||||
extension Logger.Level: @retroactive ExpressibleByArgument {}
|
||||
extension Logger.Level: @retroactive ExpressibleByArgument {
|
||||
public init?(argument: String) {
|
||||
self.init(rawValue: argument)
|
||||
}
|
||||
}
|
||||
#else
|
||||
extension Logger.Level: ExpressibleByArgument {}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user