From 2107467fc5d00bae29bd52f7a1647846a8614c39 Mon Sep 17 00:00:00 2001 From: Mikhail Knyazhev Date: Mon, 20 Jun 2022 00:06:38 +0300 Subject: [PATCH] update vendors --- go.mod | 2 +- go.sum | 2 ++ plugins/database/mysql.go | 16 ++++++++-------- plugins/database/sqlite.go | 20 ++++++++++---------- plugins/http/router.go | 10 ++++++++++ 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index 9f60090..4fe6b1d 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/deweppro/go-errors v0.0.4 github.com/deweppro/go-http v1.4.3 github.com/deweppro/go-logger v1.3.0 - github.com/deweppro/go-orm v1.0.6 + github.com/deweppro/go-orm v1.1.0 github.com/mailru/easyjson v0.7.7 github.com/oschwald/geoip2-golang v1.7.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index c8a2683..90974ce 100644 --- a/go.sum +++ b/go.sum @@ -15,6 +15,8 @@ github.com/deweppro/go-logger v1.3.0 h1:KN6RQmb6IoNBxQ7zx7Y1AtptHeL//FRgvQyEF5Pr github.com/deweppro/go-logger v1.3.0/go.mod h1:jxBBLyHmIvJ4erGUj5qeE6ir36ztyAL1pI+9GymOHVI= github.com/deweppro/go-orm v1.0.6 h1:HoM9SniQTI6oJ95EBEW4MX0vWhZPuVj5Qxp6l9B4oVU= github.com/deweppro/go-orm v1.0.6/go.mod h1:JEbxJLmXMjSOtlwhuJmrJKZRLhcJcexRvGZ6hgautaw= +github.com/deweppro/go-orm v1.1.0 h1:CmW1OU+W6mn0Nk1MdoMf6PWxP12nIK/sXImboIwindw= +github.com/deweppro/go-orm v1.1.0/go.mod h1:JEbxJLmXMjSOtlwhuJmrJKZRLhcJcexRvGZ6hgautaw= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= diff --git a/plugins/database/mysql.go b/plugins/database/mysql.go index 40bdb63..45b14ac 100644 --- a/plugins/database/mysql.go +++ b/plugins/database/mysql.go @@ -18,8 +18,8 @@ type ConfigMysql struct { //List getting all configs func (v *ConfigMysql) List() (list []schema.ItemInterface) { - for _, item := range v.Pool { - list = append(list, item) + for _, vv := range v.Pool { + list = append(list, vv) } return } @@ -71,7 +71,7 @@ type ( //MySQL connection MySQL interface MySQL interface { - Pool(name string) orm.StmtInterface + Pool(name string) *orm.Stmt } ) @@ -79,16 +79,16 @@ func (v *mysqlProvider) Up() error { if err := v.conn.Reconnect(); err != nil { return err } - for _, item := range v.conf.Pool { - p, err := v.conn.Pool(item.Name) + for _, vv := range v.conf.Pool { + p, err := v.conn.Pool(vv.Name) if err != nil { - return fmt.Errorf("pool `%s`: %w", item.Name, err) + return fmt.Errorf("pool `%s`: %w", vv.Name, err) } if err = p.Ping(); err != nil { - return fmt.Errorf("pool `%s`: %w", item.Name, err) + return fmt.Errorf("pool `%s`: %w", vv.Name, err) } v.log.WithFields( - logger.Fields{item.Name: fmt.Sprintf("%s:%d", item.Host, item.Port)}, + logger.Fields{vv.Name: fmt.Sprintf("%s:%d", vv.Host, vv.Port)}, ).Infof("MySQL connect") } return nil diff --git a/plugins/database/sqlite.go b/plugins/database/sqlite.go index c69fb5d..deb0acf 100644 --- a/plugins/database/sqlite.go +++ b/plugins/database/sqlite.go @@ -40,8 +40,8 @@ func (v *ConfigSqlite) Default() { //List getting all configs func (v *ConfigSqlite) List() (list []schema.ItemInterface) { - for _, item := range v.Pool { - list = append(list, item) + for _, vv := range v.Pool { + list = append(list, vv) } return } @@ -76,7 +76,7 @@ type ( //SQLite connection SQLite interface SQLite interface { - Pool(name string) orm.StmtInterface + Pool(name string) *orm.Stmt } ) @@ -84,18 +84,18 @@ func (v *sqliteProvider) Up() error { if err := v.conn.Reconnect(); err != nil { return err } - for _, item := range v.conf.Pool { - p, err := v.conn.Pool(item.Name) + for _, vv := range v.conf.Pool { + p, err := v.conn.Pool(vv.Name) if err != nil { - return fmt.Errorf("pool `%s`: %w", item.Name, err) + return fmt.Errorf("pool `%s`: %w", vv.Name, err) } if err = p.Ping(); err != nil { - return fmt.Errorf("pool `%s`: %w", item.Name, err) + return fmt.Errorf("pool `%s`: %w", vv.Name, err) } - if err = v.migration(p, item.InitMigration); err != nil { - return fmt.Errorf("pool `%s`: %w", item.Name, err) + if err = v.migration(p, vv.InitMigration); err != nil { + return fmt.Errorf("pool `%s`: %w", vv.Name, err) } - v.log.WithFields(logger.Fields{item.Name: item.File}).Infof("SQLite connect") + v.log.WithFields(logger.Fields{vv.Name: vv.File}).Infof("SQLite connect") } return nil } diff --git a/plugins/http/router.go b/plugins/http/router.go index 9f1deef..083b555 100644 --- a/plugins/http/router.go +++ b/plugins/http/router.go @@ -41,6 +41,8 @@ type ( SetBody(code int) BodyWriter Context() context.Context Log() logger.LogWriter + Request() *nethttp.Request + Response() nethttp.ResponseWriter } ) @@ -52,6 +54,14 @@ func newCtx(w nethttp.ResponseWriter, r *nethttp.Request, l logger.Logger) *ctx } } +func (v *ctx) Request() *nethttp.Request { + return v.r +} + +func (v *ctx) Response() nethttp.ResponseWriter { + return v.w +} + type ( //Paramer interface for typing a parameter from a URL Paramer interface {