- Proposal: SE-NNNN
- Author: Paul Cantrell
- Status: Awaiting review
- Review manager: TBD
This proposal provides a robust, generalized mechanism for altering the behavior and API design of third-party libraries.
| [Siesta:configuration] URL pattern ** compiles to regex ^https:\/\/api\.github\.com\/[^:?]*($|\?) | |
| [Siesta:configuration] Added config 1 [**] | |
| [Siesta:configuration] URL pattern /search/** compiles to regex ^https:\/\/api\.github\.com\/search\/[^:?]*($|\?) | |
| [Siesta:configuration] Added config 2 [/search/**] | |
| [Siesta:configuration] URL pattern /users/* compiles to regex ^https:\/\/api\.github\.com\/users\/[^/:?]*($|\?) | |
| [Siesta:configuration] Added config 3 [/users/* : JSON → User] | |
| [Siesta:configuration] URL pattern /users/*/repos compiles to regex ^https:\/\/api\.github\.com\/users\/[^/:?]*\/repos($|\?) | |
| [Siesta:configuration] Added config 4 [/users/*/repos : JSON → Array<Repository>] | |
| [Siesta:configuration] URL pattern /search/repositories compiles to regex ^https:\/\/api\.github\.com\/search\/repositories($|\?) | |
| [Siesta:configuration] Added config 5 [/search/repositories : JSON → Array<Repository>] |
| import Foundation | |
| // ——— The Setup ——— | |
| protocol Foo | |
| { | |
| associatedtype Bar | |
| func modify(bar: Bar) -> Bar | |
| } |
This proposal provides a robust, generalized mechanism for altering the behavior and API design of third-party libraries.
| Siesta.enabledLogCategories = LogCategory.all | |
| let service = Service(baseURL: myBaseURL) | |
| service.configureTransformer("**") { (content: NSData, entity) -> NSXMLDocument? in | |
| return try? NSXMLDocument(data: content, options: 0) | |
| } | |
| service.resource("foo.xml").load() |
| import Foundation | |
| extension Array | |
| { | |
| func median() -> Element | |
| { return self[count / 2] } | |
| } | |
| func time(name: String, iters: Int, closure: Void -> Void) -> NSTimeInterval | |
| { |
Proposed changes to Siesta’s API before it hits the 1.0 freeze. Please post your feedback on this document to the accompanying Github issue.
“Prefer to follow the language’s defaults for the presence of argument labels”
These changes seem good:
Entity.init(_:_:) → init(response:content:)Error.init(_:_:_:userMessage:) → init(response:content:cause:userMessage:)
| @media (-webkit-min-device-pixel-ratio: 2) { | |
| img { | |
| image-rendering: -webkit-optimize-contrast; | |
| image-rendering: optimize-contrast; | |
| } | |
| } |
| protocol Tensor { | |
| static var numberOfDims: Int { get } | |
| } | |
| struct NestedTensor<Element: Tensor>: Tensor { | |
| static var numberOfDims: Int { | |
| return 1 + Element.numberOfDims | |
| } | |
| // ...etc... |
| extension TypedContentAccessors { | |
| /** | |
| Adds a `.json` convenience property to resources that returns a SwiftyJSON `JSON` wrapper. | |
| If there is no data, then the property returns `JSON([:])`. | |
| Note that by default, Siesta parses data based on content type. This accessor is only a way | |
| of conveniently donwcasting and defaulting the data that Siesta has already parsed. (Parsing | |
| happens off the main thread in a GCD queue, never in response one of these content accessors.) | |
| To produce a custom data type that Siesta doesn’t already know how to parse as a Siesta | |
| resource’s content, you’ll need to add a custom `ResponseTransformer`. |
| // | |
| // KittenTest.swift | |
| // KittenTest | |
| // | |
| // Created by Paul on 2015/9/13. | |
| // Copyright © 2015 Kodama Software. All rights reserved. | |
| // | |
| import Foundation |