-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Leaf 4.0.0-tau tau is the final prerelease of LeafKit 1.0 and Leaf4. This is a massive rebuild from the previous prerelease version and entirely replaces the architecture for extending the language; as such, there is no direct transition path for converting LeafTag objects to the new architecture directly. Migration documents are coming soon to address how that functionality has improved and changed.
- Loading branch information
Showing
24 changed files
with
745 additions
and
542 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Vapor | ||
|
||
internal typealias ELF = EventLoopFuture | ||
internal typealias LFMIndexing = LeafFileMiddleware.DirectoryIndexing | ||
internal typealias Record = (process: Bool, modTime: Date) | ||
|
||
internal extension Request { | ||
var eL: EventLoop { eventLoop } | ||
func fail<T>(_ error: Error) -> ELF<T> { eL.makeFailedFuture(error) } | ||
func succeed<T>(_ value: T) -> ELF<T> { eL.makeSucceededFuture(value) } | ||
} | ||
|
||
internal extension LeafEngine { | ||
var eL: EventLoop { eventLoop } | ||
func fail<T>(_ error: Error) -> ELF<T> { eL.makeFailedFuture(error) } | ||
func succeed<T>(_ value: T) -> ELF<T> { eL.makeSucceededFuture(value) } | ||
} | ||
|
||
internal extension String { | ||
var fileExt: String { | ||
if let i = lastIndex(of: ".") { return String(self[index(after: i)..<endIndex]) } | ||
return "" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Foundation | ||
import Vapor | ||
|
||
extension URL { | ||
var _leafData: LeafData { | ||
var values = (try? resourceValues(forKeys: .init(LFMIndexing.keys)))?._leafData ?? [:] | ||
values["name"] = lastPathComponent | ||
values["absolutePath"] = absoluteString | ||
values["pathComponents"] = pathComponents | ||
values["mimeType"] = HTTPMediaType.fileExtension(pathExtension) ?? .plainText | ||
return .dictionary(values) | ||
} | ||
} | ||
|
||
extension URLResourceValues { | ||
var _leafData: [String: LeafDataRepresentable] {[ | ||
"isApplication": isApplication, | ||
"isDirectory": isDirectory, | ||
"isRegularFile": isRegularFile, | ||
"isHidden": isHidden, | ||
"isSymbolicLink": isSymbolicLink, | ||
"fileSize": fileSize, | ||
"creationDate": creationDate, // returns nil on Ubuntu xenial | ||
"contentModificationDate": contentModificationDate, | ||
]} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Vapor | ||
|
||
extension HTTPMediaType: LeafDataRepresentable { | ||
public static var leafDataType: LeafDataType? { .dictionary } | ||
public var leafData: LeafData { .dictionary([ | ||
"type": type, | ||
"subType": subType, | ||
"parameters": parameters, | ||
"serialized": serialize(), | ||
]) } | ||
} |
Oops, something went wrong.