Browse Source

Add rate limiting requests per minute field to settings

feature/add-rate-limiting
Fabian Vowie 3 years ago
parent
commit
b87a2e4b0b
No known key found for this signature in database GPG Key ID: C27317C33B27C410
  1. 2
      main.go
  2. 2
      settings/settings.go
  3. 1
      settings/settings_test.go

2
main.go

@ -61,7 +61,7 @@ func main() {
pipes := pipelines.LoadPipelines()
authMiddleware := middlewares.CreateAuthenticationMiddleware(appSettings.Token)
rateLimiterMiddleware, err := middlewares.CreateRateLimiterMiddleware(2)
rateLimiterMiddleware, err := middlewares.CreateRateLimiterMiddleware(appSettings.RequestsPerMinute)
if err != nil {
panic(err)
}

2
settings/settings.go

@ -17,6 +17,7 @@ type FileSystemType int
type Settings struct {
Endpoint string `json:"endpoint"`
Token string `json:"token"`
RequestsPerMinute int `json:"requests_per_minute"`
StorageProvider StorageSettings `json:"storage_provider"`
}
@ -51,6 +52,7 @@ func LoadSettings(fileSystem afero.Fs) (Settings, error) {
defaultSettings := Settings{
Endpoint: "127.0.0.1:8000",
Token: "changeme",
RequestsPerMinute: 20,
StorageProvider: StorageSettings{
Type: Local,
BasePath: "assets",

1
settings/settings_test.go

@ -13,6 +13,7 @@ func TestSettingsParsing(t *testing.T) {
const file string = `{
"endpoint": "0.0.0.0:8000",
"token": "foobar",
"requests_per_minute": 20,
"storage_provider": {
"type": 0,
"base_path": "assets"

Loading…
Cancel
Save