From f10d0f634f32a6c50459588d9683ecb2783e8025 Mon Sep 17 00:00:00 2001 From: Fabian Vowie Date: Sat, 15 Jan 2022 15:19:11 +0100 Subject: [PATCH] Fix store methods not being public --- lithium.log | 11 +++++++++++ settings.json | 16 ++++++++++++++++ storage/storage.go | 10 +++++----- storage/storage_test.go | 4 ++-- 4 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 lithium.log create mode 100755 settings.json diff --git a/lithium.log b/lithium.log new file mode 100644 index 0000000..a33a199 --- /dev/null +++ b/lithium.log @@ -0,0 +1,11 @@ +{"level":"info","msg":"Pipeline routes registered successfully","time":"2022-01-23T18:28:12+01:00"} +{"level":"info","msg":"Lithium started, listening for requests...","time":"2022-01-23T18:28:12+01:00"} +{"level":"info","msg":"Pipeline routes registered successfully","time":"2022-01-23T18:28:17+01:00"} +{"level":"info","msg":"Lithium started, listening for requests...","time":"2022-01-23T18:28:17+01:00"} +{"level":"info","msg":"Lithium started, listening for requests...","time":"2022-01-26T17:37:28+01:00"} +{"level":"info","msg":"Lithium started, listening for requests...","time":"2022-01-26T17:47:13+01:00"} +{"level":"info","msg":"Lithium started, listening for requests...","time":"2022-01-26T17:48:17+01:00"} +{"level":"info","msg":"Lithium started, listening for requests...","time":"2022-02-06T15:30:47+01:00"} +{"level":"info","msg":"Lithium started, listening for requests...","time":"2022-02-06T15:38:27+01:00"} +{"level":"info","msg":"Lithium started, listening for requests...","time":"2022-02-06T15:45:25+01:00"} +{"level":"info","msg":"Lithium started, listening for requests...","time":"2022-02-06T16:03:30+01:00"} diff --git a/settings.json b/settings.json new file mode 100755 index 0000000..d64ebd4 --- /dev/null +++ b/settings.json @@ -0,0 +1,16 @@ +{ + "endpoint": "127.0.0.1:8000", + "authentication": { + "enabled": true, + "token": "changeme" + }, + "rate_limiter": { + "enabled": true, + "requests_per_minute": 20, + "allowed_burst": 5 + }, + "storage_provider": { + "type": 0, + "base_path": "assets" + } +} \ No newline at end of file diff --git a/storage/storage.go b/storage/storage.go index bc77f19..095c615 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -8,8 +8,8 @@ import ( ) type IStorageProvider interface { - storeRaw(bucketName string, objectName string, data []byte) string - storeExisting(bucketName string, objectName string, existingFilePath string) string + StoreRaw(bucketName string, objectName string, data []byte) string + StoreExisting(bucketName string, objectName string, existingFilePath string) string } type FileSystemStorageProvider struct { @@ -17,7 +17,7 @@ type FileSystemStorageProvider struct { basePath string } -func (sp FileSystemStorageProvider) storeRaw(bucketName string, objectName string, data []byte) string { +func (sp FileSystemStorageProvider) StoreRaw(bucketName string, objectName string, data []byte) string { directoryPath := filepath.Join(sp.basePath, bucketName) sp.fileSystem.MkdirAll(directoryPath, os.ModePerm) @@ -29,8 +29,8 @@ func (sp FileSystemStorageProvider) storeRaw(bucketName string, objectName strin return filePath } -func (sp FileSystemStorageProvider) storeExisting(bucketName string, objectName string, existingFilePath string) string { +func (sp FileSystemStorageProvider) StoreExisting(bucketName string, objectName string, existingFilePath string) string { bytesRead, _ := afero.ReadFile(sp.fileSystem, existingFilePath) - return sp.storeRaw(bucketName, objectName, bytesRead) + return sp.StoreRaw(bucketName, objectName, bytesRead) } diff --git a/storage/storage_test.go b/storage/storage_test.go index bf2c515..d0aa620 100644 --- a/storage/storage_test.go +++ b/storage/storage_test.go @@ -19,7 +19,7 @@ func TestFileSystemStorageProvider(t *testing.T) { basePath: "/tmp/foo/bar", } - finalPath := provider.storeRaw("test", "test.bin", dummyData) + finalPath := provider.StoreRaw("test", "test.bin", dummyData) assert.Equal(t, "/tmp/foo/bar/test/test.bin", finalPath) exists, _ := afero.Exists(fileSystem, "/tmp/foo/bar/test/test.bin") @@ -39,7 +39,7 @@ func TestFileSystemStorageProvider(t *testing.T) { basePath: "/tmp/foo/bar", } - finalPath := provider.storeExisting("test", "test.bin", "/tmp/existing.bin") + finalPath := provider.StoreExisting("test", "test.bin", "/tmp/existing.bin") assert.Equal(t, "/tmp/foo/bar/test/test.bin", finalPath) exists, _ := afero.Exists(fileSystem, "/tmp/foo/bar/test/test.bin")