Skip to content

Commit 040c3e4

Browse files
committed
Merge branch 'release/1.0.0'
2 parents 8d89720 + 29e8903 commit 040c3e4

File tree

6 files changed

+492
-6
lines changed

6 files changed

+492
-6
lines changed

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ xcuserdata/
1919

2020
## Other
2121
*.moved-aside
22-
*.xccheckout
23-
*.xcscmblueprint
22+
*.xcuserstate
2423

2524
## Obj-C/Swift specific
2625
*.hmap
@@ -35,9 +34,10 @@ playground.xcworkspace
3534
# Swift Package Manager
3635
#
3736
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
38-
# Packages/
39-
# Package.pins
37+
Packages/
4038
.build/
39+
*.xcodeproj
40+
Package.pins
4141

4242
# CocoaPods
4343
#
@@ -59,7 +59,7 @@ Carthage/Build
5959
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
6060
# screenshots whenever they are needed.
6161
# For more information about the recommended setup visit:
62-
# https://docs.fastlane.tools/best-practices/source-control/#source-control
62+
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
6363

6464
fastlane/report.xml
6565
fastlane/Preview.html

CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [contact@digipolitan.com](mailto:contact@digipolitan.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

CONTRIBUTING.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Contributing to perfect-blink-swift
2+
3+
First off, thanks for taking the time to contribute! :tada::+1:
4+
5+
The following is a set of guidelines for contributing to Digipolitan and its packages, which are hosted in the [Digipolitan Organization](https://github.com/digipolitan) on GitHub.
6+
These are just guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
7+
8+
#### Table Of Contents
9+
10+
[What should I know before I get started?](#what-should-i-know-before-i-get-started)
11+
* [Code of Conduct](#code-of-conduct)
12+
13+
[How Can I Contribute?](#how-can-i-contribute)
14+
* [Reporting Bugs](#reporting-bugs)
15+
16+
## What should I know before I get started?
17+
18+
### Code of Conduct
19+
20+
This project adheres to the Contributor Covenant [code of conduct](CODE_OF_CONDUCT.md).
21+
By participating, you are expected to uphold this code.
22+
Please report unacceptable behavior to [contact@digipolitan.com](mailto:contact@digipolitan.com).
23+
24+
### Reporting Bugs
25+
26+
This section guides you through submitting a bug report for Digipolitan. Following these guidelines helps maintainers and the community understand your report :pencil:, reproduce the behavior :computer: :computer:, and find related reports :mag_right:.
27+
28+
Before creating bug reports, please check [this list](#before-submitting-a-bug-report) as you might find out that you don't need to create one. When you are creating a bug report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). If you'd like, you can use [this template](#template-for-submitting-bug-reports) to structure the information.
29+
30+
#### Before Submitting A Bug Report
31+
32+
* **Perform a [search](https://github.com/issues?q=+is%3Aissue+user%3Adigipolitan)** to see if the problem has already been reported. If it has, add a comment to the existing issue instead of opening a new one.
33+
34+
#### How Do I Submit A (Good) Bug Report?
35+
36+
Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). After you've determined
37+
38+
Explain the problem and include additional details to help maintainers reproduce the problem:
39+
40+
* **Use a clear and descriptive title** for the issue to identify the problem.
41+
* **Describe the exact steps which reproduce the problem** in as many details as possible.
42+
* **Provide specific examples to demonstrate the steps**. Include links to files or GitHub projects, or copy/pasteable snippets, which you use in those examples. If you're providing snippets in the issue, use [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines).
43+
* **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior.
44+
* **Explain which behavior you expected to see instead and why.**
45+
* **Include screenshots and animated GIFs** which show you following the described steps and clearly demonstrate the problem.
46+
* **If you're reporting that perfect-blink-swift crashed**, include a crash report with a stack trace from the operating system. On iOS, the crash report is available in Xcode, on macOS, the crash report will be available in `Console.app` under "Diagnostic and usage information" > "User diagnostic reports". Include the crash report in the issue in a [code block](https://help.github.com/articles/markdown-basics/#multiple-lines), a [file attachment](https://help.github.com/articles/file-attachments-on-issues-and-pull-requests/), or put it in a [gist](https://gist.github.com/) and provide link to that gist.
47+
* **If the problem is related to performance**, include a CPU profile capture and a screenshot with your report.
48+
* **If the problem wasn't triggered by a specific action**, describe what you were doing before the problem happened and share more information using the guidelines below.
49+
50+
Provide more context by answering these questions:
51+
52+
* **Did the problem start happening recently** (e.g. after updating to a new version of perfect-blink-swift) or was this always a problem?
53+
* If the problem started happening recently, **can you reproduce the problem in an older version of perfect-blink-swift ?** What's the most recent version in which the problem doesn't happen? You can download older versions of perfect-blink-swift from [the releases page](https://github.com/digipolitan/perfect-blink-swift/releases).
54+
* **Can you reliably reproduce the issue?** If not, provide details about how often the problem happens and under which conditions it normally happens.
55+
56+
Include details about your configuration and environment:
57+
58+
* **Which version of perfect-blink-swift are you using?
59+
* **What's the name and version of the macOS or iOS you're using**?
60+
61+
#### Template For Submitting Bug Reports
62+
63+
[Short description of problem here]
64+
65+
**Reproduction Steps:**
66+
67+
1. [First Step]
68+
2. [Second Step]
69+
3. [Other Steps...]
70+
71+
**Expected behavior:**
72+
73+
[Describe expected behavior here]
74+
75+
**Observed behavior:**
76+
77+
[Describe observed behavior here]
78+
79+
**Screenshots and GIFs**
80+
81+
![Screenshots and GIFs which follow reproduction steps to demonstrate the problem](url)
82+
83+
**perfect-blink-swift version:** [Enter perfect-blink-swift version here]
84+
**OS and version:** [Enter macOS / iOS / linux name and version here]
85+
86+
**Installed packages:**
87+
88+
[List of installed packages here]
89+
90+
**Additional information:**
91+
92+
* Problem started happening recently, didn't happen in an older version of perfect-blink-swift: [Yes/No]
93+
* Problem can be reliably reproduced, doesn't happen randomly: [Yes/No]
94+
* Problem happens with all files and projects, not only some files or projects: [Yes/No]

Package.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// swift-tools-version:3.1
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "PerfectBlink",
7+
dependencies: [
8+
.Package(url: "https://github.com/Digipolitan/perfect-middleware-swift.git", majorVersion: 1)
9+
]
10+
)

README.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,100 @@
1-
# perfect-blink-swift
1+
PerfectBlink
2+
=================================
3+
4+
[![Twitter](https://img.shields.io/badge/twitter-@Digipolitan-blue.svg?style=flat)](http://twitter.com/Digipolitan)
5+
6+
Perfect Blink middleware swift is a request parser
7+
8+
Parse incoming request body, query, url parameters before the route handler, data available under the context.blink.
9+
10+
## Installation
11+
12+
### Swift Package Manager
13+
14+
To install PerfectBlink with SPM, add the following lines to your `Package.swift`.
15+
16+
```swift
17+
import PackageDescription
18+
19+
let package = Package(
20+
name: "XXX",
21+
dependencies: [
22+
.Package(url: "https://github.com/Digipolitan/perfect-blink-swift.git", majorVersion: 1)
23+
]
24+
)
25+
```
26+
27+
## The Basics
28+
29+
Create a RouterMiddleware and register the blink middleware before all routes handlers
30+
31+
```swift
32+
let server = HTTPServer()
33+
34+
let router = RouterMiddleware()
35+
36+
router.use(event: .beforeAll, middleware: Blink.shared)
37+
38+
router.post(path: "/").bind { (context) in
39+
guard let body = context.blink.body as? [String: Any],
40+
let name = body["name"] as? String else {
41+
context.next()
42+
return
43+
}
44+
context.response.setBody(string: name).completed()
45+
context.next()
46+
}
47+
48+
server.use(router: router)
49+
50+
server.serverPort = 8887
51+
52+
do {
53+
try server.start()
54+
print("Server listening on port \(server.serverPort)")
55+
} catch PerfectError.networkError(let err, let msg) {
56+
print("Network error thrown: \(err) \(msg)")
57+
}
58+
```
59+
60+
It's possible to register a specific type to parse for only one route as follow :
61+
```swift
62+
router.post(path: "/")
63+
.bind(Blink.shared.json())
64+
.bind { (context) in
65+
guard let body = context.blink.body as? [String: Any] {
66+
context.next()
67+
return
68+
}
69+
print(body)
70+
context.next()
71+
}
72+
```
73+
74+
You can parse query parameters and url parameters for only one route as follow :
75+
```swift
76+
router.get(path: "/")
77+
.bind(Blink.shared.query())
78+
.bind(Blink.shared.params())
79+
.bind { (context) in
80+
guard let query = context.blink.query,
81+
let name = query["name"] {
82+
context.next()
83+
return
84+
}
85+
context.response.setBody(string: name).completed()
86+
context.next()
87+
}
88+
```
89+
90+
## Contributing
91+
92+
See [CONTRIBUTING.md](CONTRIBUTING.md) for more details!
93+
94+
This project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
95+
By participating, you are expected to uphold this code. Please report
96+
unacceptable behavior to [contact@digipolitan.com](mailto:contact@digipolitan.com).
97+
98+
## License
99+
100+
PerfectBlink is licensed under the [BSD 3-Clause license](LICENSE).

0 commit comments

Comments
 (0)