Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/Avanade/approval-system
Browse files Browse the repository at this point in the history
 into 114-refactor-myrequests-page

Signed-off-by: Ismael Ibuan <[email protected]>
  • Loading branch information
iibuan committed Oct 8, 2024
2 parents c5607be + 57a2bc7 commit 8062e90
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/goapp/infrastructure/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,44 @@ func (d *Database) Connect() (*sql.DB, error) {
}

func (d *Database) Query(query string, args ...any) (*sql.Rows, error) {
con, err := d.Connect()
conn, err := d.Connect()
if err != nil {
return nil, err
}
defer con.Close()
defer conn.Close()

ctx := context.Background()
rows, err := con.QueryContext(ctx, query, args...)
rows, err := conn.QueryContext(ctx, query, args...)
if err != nil {
return nil, err
}
return rows, nil
}

func (d *Database) QueryRow(query string, args ...any) (*sql.Row, error) {
con, err := d.Connect()
conn, err := d.Connect()
if err != nil {
return nil, err
}
defer con.Close()
defer conn.Close()

ctx := context.Background()
row := con.QueryRowContext(ctx, query, args...)
row := conn.QueryRowContext(ctx, query, args...)
if row == nil {
err = fmt.Errorf("QueryRowContext returned nil")
}
return row, nil
}

func (d *Database) Execute(query string, args ...any) error {
con, err := d.Connect()
conn, err := d.Connect()
if err != nil {
return err
}
defer con.Close()
defer conn.Close()

ctx := context.Background()
_, err = con.ExecContext(ctx, query, args...)
_, err = conn.ExecContext(ctx, query, args...)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions src/goapp/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func ManagedIdentityAuth() Middleware {

// Chain applies middlewares to a http.HandlerFunc
func Chain(f http.HandlerFunc, middlewares ...Middleware) http.HandlerFunc {
for _, m := range middlewares {
f = m(f)
for i := len(middlewares) - 1; i >= 0; i-- {
f = middlewares[i](f)
}
return f
}

0 comments on commit 8062e90

Please sign in to comment.