mirror of
https://github.com/gmemstr/sliproad.git
synced 2024-09-19 16:11:11 +01:00
e1b8c50d55
Added DELETE handler to files endpoint for deleting files and directories, along with new handling for creating directories, as specified with the `X-NAS-Type` header - if this is set to "directory", a new directory is created with the path of the request. Otherwise, an attempt to parse the file from form data is done as before. Also added buttons to interact with the new functionality in the default frontend.
30 lines
659 B
Go
30 lines
659 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gmemstr/nas/files"
|
|
"github.com/gmemstr/nas/router"
|
|
"github.com/go-yaml/yaml"
|
|
"io/ioutil"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
// Main function that defines routes
|
|
func main() {
|
|
// Initialize file providers.
|
|
file, err := ioutil.ReadFile("providers.yml")
|
|
if err != nil {
|
|
fmt.Println("Unable to read providers.yml file, does it exist?")
|
|
}
|
|
err = yaml.Unmarshal(file, &files.ProviderConfig)
|
|
if err != nil {
|
|
fmt.Println("Unable to parse providers.yml file, is it correct?")
|
|
}
|
|
files.SetupProviders()
|
|
|
|
r := router.Init()
|
|
fmt.Println("Your NAS instance is live on port :3000")
|
|
log.Fatal(http.ListenAndServe(":3000", r))
|
|
}
|