clean code
This commit is contained in:
parent
6b08576d63
commit
969bd7f618
|
@ -0,0 +1 @@
|
||||||
|
cmd/review/config.conf
|
|
@ -1 +0,0 @@
|
||||||
../../config_example.conf
|
|
|
@ -30,7 +30,7 @@ func main() {
|
||||||
log.Log.Info("Starting rezension monolith")
|
log.Log.Info("Starting rezension monolith")
|
||||||
|
|
||||||
err := database.Open(config.Database)
|
err := database.Open(config.Database)
|
||||||
if err != nil{
|
if err != nil {
|
||||||
log.Log.Panic(err)
|
log.Log.Panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,21 +2,20 @@ package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
|
||||||
_ "github.com/jinzhu/gorm/dialects/postgres"
|
_ "github.com/jinzhu/gorm/dialects/postgres"
|
||||||
|
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Write *gorm.DB
|
Write *gorm.DB
|
||||||
Read *gorm.DB
|
Read *gorm.DB
|
||||||
config *Config
|
config *Config
|
||||||
models []interface{}
|
models []interface{}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Type string
|
Type string
|
||||||
Connection string
|
Connection string
|
||||||
ReadConnection string
|
ReadConnection string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
package database
|
package database
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
var Log *logger.Logger
|
var Log *logger.Logger
|
||||||
|
|
||||||
func init(){
|
func init() {
|
||||||
Log = logger.New()
|
Log = logger.New()
|
||||||
// Enable fallback if core logger is used:
|
// Enable fallback if core logger is used:
|
||||||
log.SetOutput(Log.Writer())
|
log.SetOutput(Log.Writer())
|
||||||
|
@ -22,8 +22,8 @@ func HTTP(r *http.Request) *logger.Entry {
|
||||||
ip = r.RemoteAddr
|
ip = r.RemoteAddr
|
||||||
}
|
}
|
||||||
return Log.WithFields(logger.Fields{
|
return Log.WithFields(logger.Fields{
|
||||||
"remote": ip,
|
"remote": ip,
|
||||||
"method": r.Method,
|
"method": r.Method,
|
||||||
"url": r.URL.RequestURI(),
|
"url": r.URL.RequestURI(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ func TestLog(t *testing.T) {
|
||||||
log := HTTP(req)
|
log := HTTP(req)
|
||||||
_, ok := log.Data["remote"]
|
_, ok := log.Data["remote"]
|
||||||
|
|
||||||
assertion.NotNil(ok, "remote address not set in logger")
|
assertion.NotNil(ok, "remote address not set in logger")
|
||||||
assertion.Equal("GET", log.Data["method"], "method not set in logger")
|
assertion.Equal("GET", log.Data["method"], "method not set in logger")
|
||||||
assertion.Equal("/lola/duda?q=wasd", log.Data["url"], "path not set in logger")
|
assertion.Equal("/lola/duda?q=wasd", log.Data["url"], "path not set in logger")
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,14 +5,14 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/toml"
|
"github.com/influxdata/toml"
|
||||||
|
|
||||||
"github.com/genofire/hs_master-kss-monolith/lib/log"
|
|
||||||
"github.com/genofire/hs_master-kss-monolith/lib/database"
|
"github.com/genofire/hs_master-kss-monolith/lib/database"
|
||||||
|
"github.com/genofire/hs_master-kss-monolith/lib/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
//Config the config File of this daemon
|
//Config the config File of this daemon
|
||||||
type Config struct {
|
type Config struct {
|
||||||
WebserverBind string
|
WebserverBind string
|
||||||
Database database.Config
|
Database database.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadConfigFile reads a config model from path of a yml file
|
// ReadConfigFile reads a config model from path of a yml file
|
||||||
|
|
Reference in New Issue