Browse Source

Add rate limiting explanation to readme

feature/add-rate-limiting-to-readme
Fabian Vowie 3 years ago
parent
commit
6300e945dc
No known key found for this signature in database GPG Key ID: C27317C33B27C410
  1. 54
      README.md

54
README.md

@ -10,7 +10,7 @@ Micro-service for file storage and processing written in Go.
## Requirements ## Requirements
- [Go 1.17+](https://go.dev/) - [Go 1.17+](https://go.dev/)
- [*Docker*](https://docs.docker.com/) (optional)
- [_Docker_](https://docs.docker.com/) (optional)
## Setup ## Setup
@ -56,13 +56,43 @@ go test ./... -v
docker run --rm -v "$PWD":/usr/src/lithium -w /usr/src/lithium golang:1.17 go test ./... docker run --rm -v "$PWD":/usr/src/lithium -w /usr/src/lithium golang:1.17 go test ./...
``` ```
## Configuration
Config options can be adjusted via the [`settings.json`](settings.json) file in the root directory.
```json
{
"endpoint": "0.0.0.0:8000",
"token": "changeme",
"rate_limiter": {
"requests_per_minute": 20,
"allowed_burst": 5
},
"storage_provider": {
"type": 0,
"base_path": "assets"
}
}
```
## Rate Limiting
By default, the rate limiting takes place on a per-route basis. When the limit for a specific route is hit, the response will return a status code `429: Too Many Requests`.
| Headers | Explanation |
| --------------------- | -------------------------------- |
| X-Ratelimit-Limit | Allowed requests per minute |
| X-Ratelimit-Remaining | Remaining requests |
| X-Ratelimit-Reset | Seconds until requests replenish |
## API ## API
### `GET` `/` ### `GET` `/`
Show application information.
Show application information.
**Required headers**: **Required headers**:
```shell ```shell
Authorization: Bearer <Token> Authorization: Bearer <Token>
``` ```
@ -81,6 +111,7 @@ Authorization: Bearer <Token>
Show pipeline information. Show pipeline information.
**Required headers**: **Required headers**:
```shell ```shell
Authorization: Bearer <Token> Authorization: Bearer <Token>
``` ```
@ -111,27 +142,12 @@ Authorization: Bearer <Token>
} }
``` ```
## Configuration
Config options can be adjusted via the [`settings.json`](settings.json) file in the root directory.
```json
{
"endpoint": "0.0.0.0:8000",
"token": "changeme",
"storage_provider": {
"type": 0,
"base_path": "assets"
}
}
```
## Pipelines ## Pipelines
The project uses a pipeline system defined by [JSON](https://en.wikipedia.org/wiki/JSON) files located in the [config](config) folder. The project uses a pipeline system defined by [JSON](https://en.wikipedia.org/wiki/JSON) files located in the [config](config) folder.
Take a look at the [example pipeline configuration file](config/example.json). Take a look at the [example pipeline configuration file](config/example.json).
Available pipeline `type`s: `0` (Image), `1` (Video)
Available pipeline `type`s: `0` (Image), `1` (Video)
```json ```json
{ {
@ -148,7 +164,7 @@ Available pipeline `type`s: `0` (Image), `1` (Video)
The image pipeline offers the following additional output options. The image pipeline offers the following additional output options.
Available `format` types: `jpg` (or `jpeg`), `png`, `gif`, `tif` (or `tiff`) and `bmp`
Available `format` types: `jpg` (or `jpeg`), `png`, `gif`, `tif` (or `tiff`) and `bmp`
The `quality` field can contain any integer between 1 and 100. The `quality` field can contain any integer between 1 and 100.
```json ```json

Loading…
Cancel
Save