|
@ -4,9 +4,12 @@ import ( |
|
|
"encoding/json" |
|
|
"encoding/json" |
|
|
"net/http" |
|
|
"net/http" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/geplauder/lithium/auth" |
|
|
"github.com/geplauder/lithium/pipelines" |
|
|
"github.com/geplauder/lithium/pipelines" |
|
|
|
|
|
"github.com/geplauder/lithium/settings" |
|
|
"github.com/geplauder/lithium/storage" |
|
|
"github.com/geplauder/lithium/storage" |
|
|
"github.com/gorilla/mux" |
|
|
"github.com/gorilla/mux" |
|
|
|
|
|
"github.com/spf13/afero" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
const Name string = "Lithium" |
|
|
const Name string = "Lithium" |
|
@ -42,13 +45,22 @@ func RegisterPipelineRoutes(r *mux.Router, pipelines []pipelines.IPipeline, stor |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func main() { |
|
|
func main() { |
|
|
storageProvider := storage.GetFileSystemStorageProvider("test", "") |
|
|
|
|
|
|
|
|
settings := settings.LoadSettings(afero.NewOsFs()) |
|
|
|
|
|
|
|
|
storageProvider.StoreRaw("abc", "def.test", []byte{0x12, 0x10}) |
|
|
|
|
|
|
|
|
var storageProvider storage.IStorageProvider |
|
|
|
|
|
|
|
|
|
|
|
if settings.StorageProvider.Type == 0 { |
|
|
|
|
|
storageProvider = storage.GetFileSystemStorageProvider(settings.StorageProvider.BasePath, "") |
|
|
|
|
|
} else { |
|
|
|
|
|
panic("Invalid file system provided!") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
pipes := pipelines.LoadPipelines() |
|
|
pipes := pipelines.LoadPipelines() |
|
|
|
|
|
|
|
|
|
|
|
authMiddleware := auth.CreateAuthenticationMiddleware(settings.Token) |
|
|
|
|
|
|
|
|
r := mux.NewRouter() |
|
|
r := mux.NewRouter() |
|
|
|
|
|
r.Use(authMiddleware.Middleware) |
|
|
r.HandleFunc("/", IndexHandler) |
|
|
r.HandleFunc("/", IndexHandler) |
|
|
|
|
|
|
|
|
RegisterPipelineRoutes(r, pipes, storageProvider) |
|
|
RegisterPipelineRoutes(r, pipes, storageProvider) |
|
|