mirror of
https://github.com/zhigang1992/XCallbackURL.swift.git
synced 2026-01-12 18:02:18 +08:00
42 lines
839 B
Markdown
42 lines
839 B
Markdown
# XCallbackURL.swift
|
|
|
|
## Installation
|
|
|
|
### Carthage
|
|
|
|
```ruby
|
|
github "bolasblack/XCallbackURL.swift"
|
|
```
|
|
|
|
### CocoaPods
|
|
|
|
```
|
|
# TODO
|
|
```
|
|
|
|
## Usage
|
|
|
|
```swift
|
|
XCallbackURL.sharedInstance
|
|
.processer { context in
|
|
print("I can modify context before handler get it")
|
|
return context
|
|
}
|
|
.handle("/tasks/:id") { context in
|
|
print("Searching task: \(context.params["id"]!)")
|
|
}
|
|
.handle("/tasks/new") { context in
|
|
print("Creating task")
|
|
print("Goto \(context.successURLComponents!.string) after create")
|
|
}
|
|
|
|
XCallbackURL.sharedInstance.perform(NSURL(string: "app://x-callback-url/tasks/new?x-success=launch%3A")!)
|
|
|
|
// print:
|
|
// I can return a new context
|
|
// Searching task: Optional("new")
|
|
// I can return a new context
|
|
// Creating task
|
|
// Goto Optional("launch:") after create
|
|
```
|