This repository has been archived by the owner on Apr 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bea269
commit 133ac76
Showing
3 changed files
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
coverage: | ||
range: "0...100" | ||
ignore: | ||
- "Tests/" |
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,10 @@ | ||
os: | ||
- linux | ||
- osx | ||
language: generic | ||
sudo: required | ||
dist: trusty | ||
osx_image: xcode8 | ||
script: | ||
- eval "$(curl -sL https://swift.vapor.sh/ci)" | ||
- eval "$(curl -sL https://swift.vapor.sh/codecov)" |
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,58 @@ | ||
# GateKeeper | ||
[![Language](https://img.shields.io/badge/Swift-3-brightgreen.svg)](http://swift.org) | ||
[![Build Status](https://travis-ci.org/nodes-vapor/gatekeeper.svg?branch=master)](https://travis-ci.org/nodes-vapor/gatekeeper) | ||
[![codecov](https://codecov.io/gh/nodes-vapor/gatekeeper/branch/master/graph/badge.svg)](https://codecov.io/gh/nodes-vapor/gatekeeper) | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nodes-vapor/gatekeeper/master/LICENSE) | ||
|
||
Rate Limiter and SSL enforcing middleware. | ||
|
||
## Integration | ||
Update your `Package.swift` file. | ||
```swift | ||
.Package(url: "https://github.com/nodes-vapor/paginator", majorVersion: 0) | ||
``` | ||
|
||
## Getting started ๐ | ||
Both the rate limiter and SSL-enforcing middleware are easy to configure and get running. | ||
|
||
## SSLEnforcer ๐ | ||
`SSLEnforcer` has three configurable fields: the error to be thrown, your `Droplet` and the environments you wish to enforce on. The environments defaults to `[.production]`. | ||
```swift | ||
let drop = Droplet() | ||
// this will only enforce if running in `production` mode. | ||
let enforcer = SSLEnforcer(error: Abort.notFound, drop: drop) | ||
``` | ||
|
||
If you wish to secure your endpoints during development you can do the following: | ||
```swift | ||
let enforcer = SSLEnforcer( | ||
error: Abort.notFound, | ||
drop: drop, | ||
environments: [ | ||
.production, | ||
.development | ||
] | ||
) | ||
``` | ||
|
||
## RateLimiter โฑ | ||
`RateLimiter` has two configurable fields: the maximum rate and the cache to use. If you don't supply your own cache the limiter will create its own, in-memory cache. | ||
|
||
```swift | ||
let limiter = RateLimiter(rate: Rate(10, per: .minute)) | ||
``` | ||
|
||
### The `Rate.Interval` enumeration | ||
The currently implemented intervals are: | ||
```swift | ||
case .second | ||
case .minute | ||
case .hour | ||
case .day | ||
``` | ||
|
||
## Credits ๐ | ||
This package is developed and maintained by the Vapor team at [Nodes](https://www.nodes.dk). | ||
|
||
## License ๐ | ||
This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) |