Compare commits
No commits in common. "fb2e8ff85f63b32664a798dfd385c26dffdf68f8" and "27150e9502d5452197608f9250cf5ed03fb6a503" have entirely different histories.
fb2e8ff85f
...
27150e9502
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,7 +2,7 @@
|
||||
*~
|
||||
go-bouquins
|
||||
calibre.db
|
||||
bouquins.yml
|
||||
bouquins.json
|
||||
Gopkg.lock
|
||||
vendor/
|
||||
users.db
|
||||
|
@ -70,24 +70,24 @@ var UnprotectedCalibreSuffix = [1]string{"jpg"}
|
||||
|
||||
// Conf App configuration
|
||||
type Conf struct {
|
||||
BindAddress string `yaml:"bind-address"`
|
||||
DbPath string `yaml:"db-path"`
|
||||
CalibrePath string `yaml:"calibre-path"`
|
||||
Prod bool `yaml:"prod"`
|
||||
UserDbPath string `yaml:"user-db-path"`
|
||||
CookieSecret string `yaml:"cookie-secret"`
|
||||
ExternalURL string `yaml:"external-url"`
|
||||
ProvidersConf []ProviderConf `yaml:"providers"`
|
||||
BindAddress string `json:"bind-address"`
|
||||
DbPath string `json:"db-path"`
|
||||
CalibrePath string `json:"calibre-path"`
|
||||
Prod bool `json:"prod"`
|
||||
UserDbPath string `json:"user-db-path"`
|
||||
CookieSecret string `json:"cookie-secret"`
|
||||
ExternalURL string `json:"external-url"`
|
||||
ProvidersConf []ProviderConf `json:"providers"`
|
||||
}
|
||||
|
||||
// ProviderConf OAuth2 provider configuration
|
||||
type ProviderConf struct {
|
||||
Name string `yaml:"name"`
|
||||
ClientID string `yaml:"client-id"`
|
||||
ClientSecret string `yaml:"client-secret"`
|
||||
AuthURL string `yaml:"auth-url"`
|
||||
TokenURL string `yaml:"token-url"`
|
||||
ProfileURL string `yaml:"profile-url"`
|
||||
Name string `json:"name"`
|
||||
ClientID string `json:"client-id"`
|
||||
ClientSecret string `json:"client-secret"`
|
||||
AuthURL string `json:"auth-url"`
|
||||
TokenURL string `json:"token-url"`
|
||||
ProfileURL string `json:"profile-url"`
|
||||
}
|
||||
|
||||
// Bouquins contains application common resources: templates, database
|
||||
|
1
go.mod
1
go.mod
@ -9,5 +9,4 @@ require (
|
||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
||||
golang.org/x/tools v0.0.0-20190911022129-16c5e0f7d110 // indirect
|
||||
gopkg.in/yaml.v2 v2.2.2
|
||||
)
|
||||
|
4
go.sum
4
go.sum
@ -30,7 +30,3 @@ golang.org/x/tools v0.0.0-20190911022129-16c5e0f7d110 h1:6S6bidS7O4yAwA5ORRbRIjv
|
||||
golang.org/x/tools v0.0.0-20190911022129-16c5e0f7d110/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
6
main.go
6
main.go
@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"gopkg.in/yaml.v2"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -18,14 +18,14 @@ import (
|
||||
// ReadConfig loads configuration file and initialize default value
|
||||
func ReadConfig() (*bouquins.Conf, error) {
|
||||
conf := new(bouquins.Conf)
|
||||
confPath := "bouquins.yml"
|
||||
confPath := "bouquins.json"
|
||||
if len(os.Args) > 1 {
|
||||
confPath = os.Args[1]
|
||||
}
|
||||
confFile, err := os.Open(confPath)
|
||||
if err == nil {
|
||||
defer confFile.Close()
|
||||
err = yaml.NewDecoder(confFile).Decode(conf)
|
||||
err = json.NewDecoder(confFile).Decode(conf)
|
||||
} else {
|
||||
log.Println("no conf file, using defaults")
|
||||
err = nil
|
||||
|
Loading…
Reference in New Issue
Block a user