Initial project setup - Phases 1-3 complete
This commit is contained in:
45
ProxyCore/Sources/DataLayer/Models/MapLocalRule.swift
Normal file
45
ProxyCore/Sources/DataLayer/Models/MapLocalRule.swift
Normal file
@@ -0,0 +1,45 @@
|
||||
import Foundation
|
||||
import GRDB
|
||||
|
||||
public struct MapLocalRule: Codable, FetchableRecord, MutablePersistableRecord, Identifiable, Sendable {
|
||||
public var id: Int64?
|
||||
public var name: String?
|
||||
public var urlPattern: String
|
||||
public var method: String
|
||||
public var responseStatus: Int
|
||||
public var responseHeaders: String?
|
||||
public var responseBody: Data?
|
||||
public var responseContentType: String?
|
||||
public var isEnabled: Bool
|
||||
public var createdAt: Double
|
||||
|
||||
public static let databaseTableName = "map_local_rules"
|
||||
|
||||
public mutating func didInsert(_ inserted: InsertionSuccess) {
|
||||
id = inserted.rowID
|
||||
}
|
||||
|
||||
public init(
|
||||
id: Int64? = nil,
|
||||
name: String? = nil,
|
||||
urlPattern: String,
|
||||
method: String = "ANY",
|
||||
responseStatus: Int = 200,
|
||||
responseHeaders: String? = nil,
|
||||
responseBody: Data? = nil,
|
||||
responseContentType: String? = nil,
|
||||
isEnabled: Bool = true,
|
||||
createdAt: Double = Date().timeIntervalSince1970
|
||||
) {
|
||||
self.id = id
|
||||
self.name = name
|
||||
self.urlPattern = urlPattern
|
||||
self.method = method
|
||||
self.responseStatus = responseStatus
|
||||
self.responseHeaders = responseHeaders
|
||||
self.responseBody = responseBody
|
||||
self.responseContentType = responseContentType
|
||||
self.isEnabled = isEnabled
|
||||
self.createdAt = createdAt
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user