From fafc19088ea0d45b0a87086d3cc3b83603dc9e44 Mon Sep 17 00:00:00 2001 From: Fabian Vowie Date: Sun, 23 Jan 2022 17:32:09 +0100 Subject: [PATCH] Add rate limiting explanation to readme --- README.md | 54 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 7101b4e..f9ceb39 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Micro-service for file storage and processing written in Go. ## Requirements - [Go 1.17+](https://go.dev/) -- [*Docker*](https://docs.docker.com/) (optional) +- [_Docker_](https://docs.docker.com/) (optional) ## 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 ./... ``` +## 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 ### `GET` `/` -Show application information. +Show application information. **Required headers**: + ```shell Authorization: Bearer ``` @@ -81,6 +111,7 @@ Authorization: Bearer Show pipeline information. **Required headers**: + ```shell Authorization: Bearer ``` @@ -111,27 +142,12 @@ Authorization: Bearer } ``` -## 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 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). -Available pipeline `type`s: `0` (Image), `1` (Video) +Available pipeline `type`s: `0` (Image), `1` (Video) ```json { @@ -148,7 +164,7 @@ Available pipeline `type`s: `0` (Image), `1` (Video) 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. ```json