You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SQLcommenter is a plugin/middleware/wrapper to augment application related information/tags with SQL Statements that can be used later to correlate user code with SQL statements.
4
4
@@ -7,28 +7,29 @@ SQLcommenter is a plugin/middleware/wrapper to augment application related infor
7
7
### Install from source
8
8
9
9
* Clone the source
10
-
* In terminal go inside the client folder location where we need to import google-sqlcommenter package and enter the below commands
10
+
* In terminal go inside the client folder location where we need to import sqlcommenter go-sql module and enter the below commands
11
11
12
12
```shell
13
-
go mod edit -replace google.com/sqlcommenter=path/to/google/sqlcommenter/go
13
+
go mod edit -replace google.com/sqlcommenter=path/to/google/sqlcommenter/go-sql
14
14
15
15
go mod tiny
16
+
17
+
go get google.com/sqlcommenter/gosql
16
18
```
17
19
### Install from github [To be added]
18
20
19
-
## Usages
21
+
## Usage
20
22
21
-
### go-sql-driver
22
-
Please use the sqlcommenter's default database driver to execute statements. \
23
+
Please use the sqlcommenter's default go-sql database driver to execute statements.
23
24
Due to inherent nature of Go, the safer way to pass information from framework to database driver is via `context`. So, it is recommended to use the context based methods of `DB` interface like `QueryContext`, `ExecContext` and `PrepareContext`.
Users are given control over what tags they want to append by using `sqlcommenter.CommenterOptions` struct.
32
+
Users are given control over what tags they want to append by using `core.CommenterOptions` struct.
32
33
33
34
```go
34
35
typeCommenterOptionsstruct {
@@ -41,32 +42,15 @@ type CommenterOptions struct {
41
42
}
42
43
```
43
44
44
-
### net/http
45
-
Populate the request context with sqlcommenter.AddHttpRouterTags(r) function in a custom middleware.
46
45
47
-
#### Note
48
-
* We only support the `database/sql` driver and have provided an implementation for that.
49
-
* <b>ORM related tags are added to the driver only when the tags are enabled in the commenter's driver's config and also the request context should passed to the querying functions</b>
46
+
### Framework Supported
47
+
*[http/net](.../../../http-net/README.md)
50
48
51
-
#### Example
52
-
```go
53
-
// middleware is used to intercept incoming HTTP calls and populate request context with commenter tags.
54
-
funcmiddleware(nexthttp.Handler) http.Handler {
55
-
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
56
-
ctx:= sqlcommenter.AddHttpRouterTags(r, next)
57
-
next.ServeHTTP(w, r.WithContext(ctx))
58
-
})
59
-
}
60
-
```
61
49
62
50
## Options
63
51
64
52
With Go SqlCommenter, we have configuration to choose which tags to be appended to the comment.
65
53
66
-
| Options | Included by default? | go-sql-orm | net/http | Notes |
0 commit comments