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
|
go-bouquins
|
||||||
calibre.db
|
calibre.db
|
||||||
bouquins.yml
|
bouquins.json
|
||||||
Gopkg.lock
|
Gopkg.lock
|
||||||
vendor/
|
vendor/
|
||||||
users.db
|
users.db
|
||||||
|
@ -70,24 +70,24 @@ var UnprotectedCalibreSuffix = [1]string{"jpg"}
|
|||||||
|
|
||||||
// Conf App configuration
|
// Conf App configuration
|
||||||
type Conf struct {
|
type Conf struct {
|
||||||
BindAddress string `yaml:"bind-address"`
|
BindAddress string `json:"bind-address"`
|
||||||
DbPath string `yaml:"db-path"`
|
DbPath string `json:"db-path"`
|
||||||
CalibrePath string `yaml:"calibre-path"`
|
CalibrePath string `json:"calibre-path"`
|
||||||
Prod bool `yaml:"prod"`
|
Prod bool `json:"prod"`
|
||||||
UserDbPath string `yaml:"user-db-path"`
|
UserDbPath string `json:"user-db-path"`
|
||||||
CookieSecret string `yaml:"cookie-secret"`
|
CookieSecret string `json:"cookie-secret"`
|
||||||
ExternalURL string `yaml:"external-url"`
|
ExternalURL string `json:"external-url"`
|
||||||
ProvidersConf []ProviderConf `yaml:"providers"`
|
ProvidersConf []ProviderConf `json:"providers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProviderConf OAuth2 provider configuration
|
// ProviderConf OAuth2 provider configuration
|
||||||
type ProviderConf struct {
|
type ProviderConf struct {
|
||||||
Name string `yaml:"name"`
|
Name string `json:"name"`
|
||||||
ClientID string `yaml:"client-id"`
|
ClientID string `json:"client-id"`
|
||||||
ClientSecret string `yaml:"client-secret"`
|
ClientSecret string `json:"client-secret"`
|
||||||
AuthURL string `yaml:"auth-url"`
|
AuthURL string `json:"auth-url"`
|
||||||
TokenURL string `yaml:"token-url"`
|
TokenURL string `json:"token-url"`
|
||||||
ProfileURL string `yaml:"profile-url"`
|
ProfileURL string `json:"profile-url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bouquins contains application common resources: templates, database
|
// 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/lint v0.0.0-20190909230951-414d861bb4ac // indirect
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
||||||
golang.org/x/tools v0.0.0-20190911022129-16c5e0f7d110 // indirect
|
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/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=
|
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=
|
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 (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"gopkg.in/yaml.v2"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -18,14 +18,14 @@ import (
|
|||||||
// ReadConfig loads configuration file and initialize default value
|
// ReadConfig loads configuration file and initialize default value
|
||||||
func ReadConfig() (*bouquins.Conf, error) {
|
func ReadConfig() (*bouquins.Conf, error) {
|
||||||
conf := new(bouquins.Conf)
|
conf := new(bouquins.Conf)
|
||||||
confPath := "bouquins.yml"
|
confPath := "bouquins.json"
|
||||||
if len(os.Args) > 1 {
|
if len(os.Args) > 1 {
|
||||||
confPath = os.Args[1]
|
confPath = os.Args[1]
|
||||||
}
|
}
|
||||||
confFile, err := os.Open(confPath)
|
confFile, err := os.Open(confPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
defer confFile.Close()
|
defer confFile.Close()
|
||||||
err = yaml.NewDecoder(confFile).Decode(conf)
|
err = json.NewDecoder(confFile).Decode(conf)
|
||||||
} else {
|
} else {
|
||||||
log.Println("no conf file, using defaults")
|
log.Println("no conf file, using defaults")
|
||||||
err = nil
|
err = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user