1
0
mirror of https://github.com/simon987/ws_bucket.git synced 2025-04-08 21:16:45 +00:00

Create readme

This commit is contained in:
simon987 2019-03-09 12:38:22 -05:00
parent fea86af41d
commit 04f2ff8900
2 changed files with 35 additions and 1 deletions

15
README.md Normal file

@ -0,0 +1,15 @@
### Environment variables
| Name | Default |
|:---|:---|
| `WS_BUCKET_ADDR` | `0.0.0.0:3020` |
| `WS_BUCKET_WORKDIR` | `./data` |
| `WS_BUCKET_LOGLEVEL` | `trace` |
| `WS_BUCKET_CONNSTR` | `host=localhost user=ws_bucket dbname=ws_bucket password=ws_bucket sslmode=disable` |
| `WS_BUCKET_DIALECT` | `postgres` |
### Running tests
```bash
cd test/
go test
```

21
main.go

@ -3,11 +3,12 @@ package main
import (
"github.com/jinzhu/gorm"
"github.com/simon987/ws_bucket/api"
"os"
)
func main() {
db, err := gorm.Open("postgres", "host=localhost user=ws_bucket dbname=ws_bucket password=ws_bucket sslmode=disable")
db, err := gorm.Open(getDialect(), getConnStr())
if err != nil {
panic(err)
}
@ -15,3 +16,21 @@ func main() {
a := api.New(db)
a.Run()
}
func getConnStr() string {
connStr := os.Getenv("WS_BUCKET_CONNSTR")
if connStr == "" {
return "host=localhost user=ws_bucket dbname=ws_bucket password=ws_bucket sslmode=disable"
} else {
return connStr
}
}
func getDialect() string {
connStr := os.Getenv("WS_BUCKET_DIALECT")
if connStr == "" {
return "postgres"
} else {
return connStr
}
}