forked from ml-archive/bugsnag
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from gotranseo/vapor4
Vapor4
- Loading branch information
Showing
6 changed files
with
45 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ bower_components/ | |
.swift-version | ||
CMakeLists.txt | ||
Package.pins | ||
|
||
.swiftpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
// swift-tools-version:4.0 | ||
|
||
// swift-tools-version:5.2 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "Bugsnag", | ||
platforms: [ | ||
.macOS(.v10_15) | ||
], | ||
products: [ | ||
.library(name: "Bugsnag", targets: ["Bugsnag"]), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0") | ||
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0") | ||
], | ||
targets: [ | ||
.target(name: "Bugsnag", dependencies: ["Vapor"]), | ||
.testTarget(name: "BugsnagTests", dependencies: ["Bugsnag"]) | ||
.target(name: "Bugsnag", dependencies: [ | ||
.product(name: "Vapor", package: "vapor"), | ||
]), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,23 @@ | ||
import Vapor | ||
|
||
public final class BugsnagProvider: Vapor.Provider { | ||
extension Application { | ||
|
||
public static var repositoryName = "bugsnag" | ||
|
||
let environment: Environment | ||
let notifyReleaseStages: [Environment]? | ||
let apiKey: String | ||
|
||
public init(environment: Environment, notifyReleaseStages: [Environment]?, apiKey: String) { | ||
self.environment = environment | ||
self.notifyReleaseStages = notifyReleaseStages | ||
self.apiKey = apiKey | ||
// MARK: - API | ||
struct BugsnagStorageKey: StorageKey { | ||
typealias Value = Bugsnag | ||
} | ||
|
||
public func register(_ services: inout Services) throws { | ||
services.register(Bugsnag.self) { container -> Bugsnag in | ||
let payloadTransformer = PayloadTransformer(environment: self.environment, apiKey: self.apiKey) | ||
let client = try container.make(Client.self) | ||
let connectionManager = ConnectionManager(url: "https://notify.bugsnag.com", client: client) | ||
|
||
let bugsnag = Bugsnag(environment: self.environment, | ||
notifyReleaseStages: self.notifyReleaseStages, | ||
connectionManager: connectionManager, | ||
transformer: payloadTransformer) | ||
|
||
return bugsnag | ||
public var bugsnag: Bugsnag { | ||
get { | ||
guard let val = self.storage[BugsnagStorageKey.self] else { fatalError() } | ||
return val | ||
} | ||
set { | ||
self.storage[BugsnagStorageKey.self] = newValue | ||
} | ||
} | ||
|
||
public func didBoot(_ container: Container) throws -> EventLoopFuture<Void> { | ||
return .done(on: container) | ||
} | ||
|
||
public func boot(_ worker: Container) throws { } | ||
} | ||
|
||
extension Request { | ||
var bugsnag: Bugsnag { self.application.bugsnag } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters