-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAPIService.swift
38 lines (32 loc) · 1.02 KB
/
APIService.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift OpenFeature open source project
//
// Copyright (c) 2025 the Swift OpenFeature project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Hummingbird
import OpenFeature
import ServiceLifecycle
public struct APIService: Service {
private let app: Application<RouterResponder<APIRequestContext>>
private let client: OpenFeatureClient
public init(router: Router<APIRequestContext>) {
client = OpenFeatureSystem.client()
router
.addMiddleware {
AuthMiddleware()
EvaluationContextMiddleware()
}
.addRoutes(FeedController().routes)
app = Application(router: router)
}
public func run() async throws {
try await app.run()
}
}