2019-02-24 08:25:39 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2020-02-24 18:07:47 +00:00
|
|
|
"github.com/gmemstr/nas/files"
|
2020-04-02 20:50:39 +01:00
|
|
|
"github.com/gmemstr/nas/router"
|
2020-02-24 18:07:47 +00:00
|
|
|
"github.com/go-yaml/yaml"
|
|
|
|
"io/ioutil"
|
2019-02-24 08:25:39 +00:00
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Main function that defines routes
|
|
|
|
func main() {
|
2020-03-19 10:13:38 +00:00
|
|
|
// Initialize file providers.
|
2020-02-24 18:07:47 +00:00
|
|
|
file, err := ioutil.ReadFile("providers.yml")
|
|
|
|
if err != nil {
|
2020-04-12 22:10:51 +01:00
|
|
|
fmt.Println("Unable to read providers.yml file, does it exist?")
|
2020-02-24 18:07:47 +00:00
|
|
|
}
|
2020-03-21 00:31:24 +00:00
|
|
|
err = yaml.Unmarshal(file, &files.ProviderConfig)
|
2020-02-24 18:07:47 +00:00
|
|
|
if err != nil {
|
2020-04-12 22:10:51 +01:00
|
|
|
fmt.Println("Unable to parse providers.yml file, is it correct?")
|
2020-02-24 18:07:47 +00:00
|
|
|
}
|
2020-03-21 00:31:24 +00:00
|
|
|
files.SetupProviders()
|
2020-02-24 18:07:47 +00:00
|
|
|
|
2019-02-24 08:25:39 +00:00
|
|
|
r := router.Init()
|
|
|
|
fmt.Println("Your NAS instance is live on port :3000")
|
|
|
|
log.Fatal(http.ListenAndServe(":3000", r))
|
|
|
|
}
|